Saturday, April 26, 2014

sed

  •   sed command examples
When you copy a DOS file to Unix, you could find \r\n in the end of each line. This example converts the DOS file format to Unix file format using sed command.

$sed 's/.$//' filename

Print file content in reverse order
$ sed -n '1!G;h;$p' thegeekstuff.txt

Add line number for all non-empty-lines in a file
$ sed '/./=' thegeekstuff.txt | sed 'N; s/\n/ /'


 
 
 

Related Posts:

  • mkdir   mkdir command examples Following example creates a directory called temp under your home directory. $ mkdir ~/temp Create nested directories using one mkdir command. If any of these directories exist already… Read More
  • ls ls command examples Display filesize in human readable format (e.g. KB, MB etc.,) $ ls -lh -rw-r----- 1 linxcare team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz Order Files Based on Last Modified Time (In Reverse Ord… Read More
  • mv mv command examples Rename file1 to file2. if file2 exists prompt for confirmation before overwritting it. $ mv -i file1 file2 Note: mv -f is just the opposite, which will overwrite file2 without prompting… Read More
  • locate   locate command examples Using locate command you can quickly search for the location of a specific file (or group of files). Locate command uses the database created by updatedb. The example below shows all f… Read More
  • mount   mount command examples To mount a file system, you should first create a directory and mount it as shown below. # mkdir /u01 # mount /dev/sdb1 /u01 You can also add this to the fstab for automatic mount… Read More

0 comments:

Post a Comment