Posts

Advanced Vi Cheat Sheet Starting/Ending Status Modes Inserting Text Motion Deleting Text Yanking Changing Text Putting Text Buffers Markers Searching Replacing Text Regular Expressions Counts Ranges Shell Functions Files VI Settings Key Mapping Other Click here for the Basic VI Cheatsheet General Notes: 1. Before doing anything to a document, type the following command followed by a carriage return: :set showmode 2. VI is CaSe SEnsItiVe!!! So make sure Caps Lock is OFF. Starting and Ending VI Starting VI vi filename Edits filename vi -r filename Edits last save version of filename after a crash vi + n filename Edits filename and places curser at line n vi + filename Edits filename and places curser on last line vi +/ string filename Edits filename and places curser on first occurance of string...

Vi or vim - Vi IMproved, a programmers text editor tutorial -- Basic

Starting the vi or Vim Editor: DESCRIPTION        Vim  is a text editor that is upwards compatible to Vi.  It can be used        to edit all kinds of plain text.  It is especially useful  for  editing        programs.        There  are a lot of enhancements above Vi: multi level undo, multi win-        dows and buffers, syntax highlighting, command line  editing,  filename        completion,   on-line   help,   visual  selection,  etc..   See  ":help        vi_diff.txt" for a summary of the differences between Vim and Vi.        While running Vim a lot of help can be obtained from the  on-line  help       ...

`sed' is a stream editor

Sed is the ultimate s tream ed itor. If that sounds strange, picture a stream flowing through a pipe. Okay, you can't see a stream if it's inside a pipe. That's what I get for attempting a flowing analogy. You want literature, read James Joyce. Examples:- [root@rhel6 rajesh]# echo day day [root@rhel6 rajesh]# echo day | sed s/day/night/ night [root@rhel6 rajesh]# echo "This is my data.." | sed s/my/your/ This is your data.. [root@rhel6 rajesh]# [root@rhel6 rajesh]# echo EVERYDAY | sed 's/day/night/' EVERYDAY [root@rhel6 rajesh]# [root@rhel6 rajesh]# echo EVERYDAY | sed 's/day/night/i'        //"i" switch to ignore case-sentivity EVERYnight [root@rhel6 rajesh]# echo "one two three, one two three four three two one one hundred" | sed 's/one/ONE/' ONE two three, one two three four three two one one hundred [root@rhel6 rajesh]# echo "one two three, one two three four three two one one hundred...

adding date to a filename

 Spliting filename & extension :- Option, 1 ========================================================= [rajesh@rhel6 ~]$ FILE=somefile.txt [rajesh@rhel6 ~]$ echo $FILE somefile.txt [rajesh@rhel6 ~]$ NAME=${FILE%.*} [rajesh@rhel6 ~]$ echo $NAME somefile [rajesh@rhel6 ~]$ EXT=${FILE#*.} [rajesh@rhel6 ~]$ echo $EXT txt [rajesh@rhel6 ~]$ DATE=`date +%d-%m-%y` [rajesh@rhel6 ~]$ echo $DATE 18-06-13 [rajesh@rhel6 ~]$ NEWFILE=${NAME}_${DATE}.${EXT} [rajesh@rhel6 ~]$ echo $NEWFILE somefile_18-06-13.txt [rajesh@rhel6 ~]$ Option,2 :However, this won't work with multiple "." in the file name. ========================================================= [rajesh@rhel6 ~]$ echo $FILE somefile.txt [rajesh@rhel6 ~]$ [rajesh@rhel6 ~]$ NAME=`echo $FILE | cut -d. -f1 ` [rajesh@rhel6 ~]$ echo $NAME somefile [rajesh@rhel6 ~]$ EXT=`echo $FILE | cut -d. -f2` [rajesh@rhel6 ~]$ echo $EXT txt

Xmanager RHEL 6 xclock :command not found -- Resolved

Image
1) If your system is entitled to Red Hat support (or if it's a CentOS machine), just yum install xorg-x11-apps. other usefull yum(1) commands: yum provides '*/xclock' yum grouplist yum groupinstall 'X Window System' Ref: http://serverfault.com/questions/206961/xwindows-on-red-hat-linux 2)check /etc/ssh/sshd_config:- #X11Forwarding no X11Forwarding yes                          <---Make sure this is not commented #X11DisplayOffset 10 #X11UseLocalhost yes #PrintMotd yes #PrintLastLog yes #TCPKeepAlive yes #UseLogin no 3)Make Xmanage run in Passive mode 4) Putty Settings :- 5) Here's the output of the screen:

Adding Extra Hard Disk Space to existing Linux System

[root@vmlinux ~]# fdisk /dev/sdb The number of cylinders for this disk is set to 2219. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs    (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action    e   extended    p   primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2219, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-2219, default 2219): Using default value 2219 Command (m for help): p Disk /dev/sdb: 18.2 GB, 18253611008 bytes 255 heads, 63 sectors/track, 2219 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes    Device Boot      Start         End      Blocks   Id  Sy...

Xargs Command Examples

xargs is a very powerful command that takes output of a command and pass it as argument of another command. Following are some practical examples on how to use xargs effectively. Xargs Example 1: When you are trying to delete too many files using rm, you may get error message: /bin/rm Argument list too long – Linux. Use xargs to avoid this problem. # find ~ -name ‘*.log’ -print0 | xargs -0 rm -f    Xargs Example 2: Get a list of all the *.conf file under /etc/. There are different ways to get the same result. Following example is only to demonstrate the use of xargs. The output of the find command in this example is passed to the ls –l one by one using xargs. # find /etc -name "*.conf" | xargs ls –l Xargs Example 3: If you have a file with list of URLs that you would like to download, you can use xargs as shown below. # cat url-list.txt | xargs wget –c Xargs Example 4: Find out all the jpg images and archive it. # find / -name *.jpg -type f -print |...