{"id":3509,"date":"2014-08-27T19:00:54","date_gmt":"2014-08-27T11:00:54","guid":{"rendered":"http:\/\/rmohan.com\/?p=3509"},"modified":"2014-08-27T19:23:51","modified_gmt":"2014-08-27T11:23:51","slug":"grep-2","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3509","title":{"rendered":"Unix commands helps"},"content":{"rendered":"<p>grep<br \/>\ngrep is a saviour command for  unix  users. grep can be used to search for patterns in a file or standard input. The pattern search includes finding  the line number of the keyword, counting the number of occurrences of a keyword  and many more. we will see in the following examples.<\/p>\n<p>Example 1) grep in its simplest form,i:e without any arguments displays  all the lines where the pattern occurs.<\/p>\n<p>\/home\/kapoor $ cat  AllPhones.lst<br \/>\nSamsung C5010 Squash : Rs. 3,245<br \/>\n Samsung C5130 : Rs. 3,500<br \/>\n LG GU285 : Rs. 3,750<br \/>\n Nokia C2 01 : Rs. 3,799<br \/>\n Nokia 2730 Classic : Rs. 3,960<br \/>\n INQ Mini 3G : Rs. 4,000<br \/>\n Spice G6500 : Rs. 4,295<br \/>\n Sony Ericsson Cedar : Rs. 5,100<br \/>\n Samsung Star Nano 3G S3370 : Rs. 5,100<br \/>\n Samsung L700 : Rs. 5,300<br \/>\n Spice QT95 : Rs. 5,500<br \/>\n nokia 7230 : Rs. 5,700<br \/>\n Sony Ericsson J105 Naite : Rs. 5,800<br \/>\n Samsung Metro 3G S5350 : Rs. 6,000<\/p>\n<p>\/home\/kapoor $ grep  Nokia  AllPhones.lst<br \/>\nNokia C2 01 : Rs. 3,799<br \/>\n Nokia 2730 Classic : Rs. 3,960     <\/p>\n<p>To  make case insensitive search use grep with \u2013i option<br \/>\ni:e  grep \u2013i Nokia  AllPhones.lst<br \/>\nnow the result would also include the line nokia 7230 : Rs. 5,700<\/p>\n<p>Example 2)<br \/>\nIt might be required for you to count the number of occurrences of a particular keyword, use  -c option .<br \/>\n\/home\/kapoor $ grep   -c  -i  Samsung   AllPhones.lst<br \/>\n5<\/p>\n<p>Remember always to use \u2013i just before the search keyword.<\/p>\n<p>Example 3)<br \/>\nYou might  be  searching a particular thing excluding a particular word, then use -v   option.<br \/>\n \/home\/kapoor $ grep  \u2013v   Samsung   AllPhones.lst<br \/>\nLG GU285 : Rs. 3,750<br \/>\n Nokia C2 01 : Rs. 3,799<br \/>\n Nokia 2730 Classic : Rs. 3,960<br \/>\n INQ Mini 3G : Rs. 4,000<br \/>\n Spice G6500 : Rs. 4,295<br \/>\nSony Ericsson Cedar : Rs. 5,100<br \/>\nSpice QT95 : Rs. 5,500<br \/>\n nokia 7230 : Rs. 5,700<br \/>\n Sony Ericsson J105 Naite : Rs. 5,800        <\/p>\n<p>Example 4)<br \/>\nWhen   you  wish to search more than one keyword   use \u2013e option of grep before each keyword.<\/p>\n<p>\/home\/kapoor $ grep -e   LG   \u2013e   \u2013i  spice  AllPhones.lst<br \/>\nLG GU285 : Rs. 3,750<br \/>\nSpice G6500 : Rs. 4,295<br \/>\nSpice QT95 : Rs. 5,500                       <\/p>\n<p>Similarly if you require to search for all other phones other than LG and spice use<br \/>\ngrep  -v  -e   LG   \u2013e   \u2013i  spice  AllPhones.lst<\/p>\n<p>Example 5)<br \/>\nTo accomplish  a search within   a searched line use pipes. suppose you are planning to buy<br \/>\n  a nokia phone other than a classic one, use grep as shown<br \/>\n\/home\/kapoor $ grep \u2013i  nokia   AllPhones.lst  |   grep  -v   \u2013i   Classic<br \/>\nNokia C2 01 : Rs. 3,799<br \/>\nnokia 7230 : Rs. 5,700<\/p>\n<p>why grep is  such a  great command  in  searching   these results for  you is that it does them amazingly fast.<\/p>\n<p>Example 6)<br \/>\nYou have seen in Example 4) how multiple keyword search was done using \u2013e option. but it becomes very lengthy and untidy to use \u2013e after each keyword if there are 100s of things to be searched.<br \/>\nIn such cases you can use grep with  -f  <file> option.the below lines show how.<\/p>\n<p>Save the list of phones in a file.<br \/>\n\/home\/kapoor $cat   >required_phones<br \/>\nSony Ericsson<br \/>\nINQ<br \/>\nNokia<br \/>\n^D<br \/>\n\/home\/kapoor $grep  \u2013f   required_phones   AllPhones.lst<br \/>\n Nokia C2 01 : Rs. 3,799<br \/>\n Nokia 2730 Classic : Rs. 3,960<br \/>\n INQ Mini 3G : Rs. 4,000<br \/>\n Sony Ericsson Cedar : Rs. 5,100<br \/>\nSony Ericsson J105 Naite : Rs. 5,800         <\/p>\n<p>Similarly you can use \u2013v  \u2013f  <file>  to  display all the lines except those in the <file><\/p>\n<p>The situation is like this. You have a key word  and you want to search it in a large number of<br \/>\nfiles in a path. The following examples (7-9)show you various techniques and scenarios.<\/p>\n<p>Example 7)<br \/>\nTo give only a list of files which contain your keyword  use \u2013l option of grep.<br \/>\nThe command below lists   all the scripts  which  uses   awk .<br \/>\n\/home\/kapoor $grep   -l    \u201cawk\u201d   *.sh<br \/>\nPattern-gen.sh<br \/>\nLarge-box.sh<\/p>\n<p>Example 8)<br \/>\nIf grep is used to search  in  a group of files for a pattern, it gives the following default output.<br \/>\n \/home\/kapoor $grep   sed  *.sh<br \/>\n pgfile-2.sh:sed -n 1,$p   $h2_file.txt<br \/>\n pgfile-2.sh:sed   &#8216;s\/;\/\/g&#8217;    $h3_file.txt<br \/>\n daily-b1.sh:sed   &#8216;s\/-\/_\/g&#8217;  prime_f.js<\/p>\n<p>If you do not want grep to display the searched filenames and only want the patterns use grep -h<br \/>\ngrep -h  sed  *.sh  gives  you the output.<br \/>\n sed -n 1,$p   $h2_file.txt<br \/>\n sed   &#8216;s\/;\/\/g&#8217;    $h3_file.txt<br \/>\n sed   &#8216;s\/-\/_\/g&#8217;  prime_f.js<\/p>\n<p>Example 9)<br \/>\nTo search for patterns recursively  among  files of directory  and its  sub directories use grep -r .<\/p>\n<p>\/home\/kapoor $grep  -l  -r  awk   *.sh<br \/>\nPattern-gen.sh<br \/>\nLarge-box.sh<br \/>\nShell1\/getfiles_2.sh<br \/>\nShell1\/remainder.sh<br \/>\nShell1\/byte-logs.sh<br \/>\nShell1\/new-scripts\/byte-logs.sh<br \/>\nShell2\/vault-value.sh<\/p>\n<p>Example 10)<br \/>\nIn shell scripts you may need to search for a pattern but do not want the command to write to<br \/>\nStandard output but you need to  decide on whether the search succeeded, then use grep \u2013q.<br \/>\n&#8230;..      #lines of the script<br \/>\n&#8230;..      \u2018\u2019<br \/>\ngrep   -q    win   victory-status.log<br \/>\nif   [   $?  -eq  0  ]<br \/>\nthen<br \/>\n flag=1<br \/>\nelse<br \/>\nflag=0<br \/>\nfi<br \/>\n..<br \/>\n..<br \/>\nHere  grep does not give any output, but  the exit condition is 0 if search is found and non zero if not found ( $?  Stores the  exit condition of the output of previous command.)<\/p>\n<p>Example 11)<br \/>\nYou can also know the line numbers of the searched patterns through grep by using \u2013n command.<\/p>\n<p>\/home\/kapoor $ grep \u2013n  error   status-run.log<br \/>\n40: error  cannot open  file  gt1.txt<br \/>\n160:error  cannot open file    uu6.txt<br \/>\n178:parse  error<\/p>\n<p>alias<\/p>\n<p>alias<\/p>\n<p>alias is one of those commands for  people who want to be lazy. you can use alias<br \/>\nin situations where it is too time consuming to type the same commands again and again.<br \/>\nBut avoid aliases to commands like rm, kill etc.<\/p>\n<p>Example. 1)<br \/>\nTo  always use vim instead of vi, and to make sure that whenever<br \/>\n there is a  system crash, network failure etc during editing ,<br \/>\nall  the contents are recovered, use the alias as follows.<br \/>\n\/home\/viru$ alias vi  = \u2018vim \u2013r\u2019<\/p>\n<p>To make this  happen every time you work after logging in, save the above line in<br \/>\nyour .profile<br \/>\ni:e in the file  $HOME\/.profile<\/p>\n<p>after saving it in .profile do not forget to run it.<br \/>\nie \/home\/viru$ . $HOME\/.profile<br \/>\n                             |<br \/>\n                             |<br \/>\n                   a dot here is necessary.<\/p>\n<p>Example2) after running .profile ,to view all the  aliases that are set globally, just enter alias.<\/p>\n<p>\/home\/viru$ alias<br \/>\nalias ls=\u2019ls \u2013lrt\u2019<br \/>\nalias psu=\u2019ps \u2013fu $LOGNAME\u2019<br \/>\nalias df =\u2018df \u2013gt\u2019<br \/>\nalias jbin=\u2019cd \/home\/viru\/utils\/java\/bin\u2019<br \/>\nalias jlib=\u2019cd \/home\/viru\/utils\/java\/lib\u2019<\/p>\n<p>seems  viru is so lazy..!!<\/p>\n<p>Example3)<br \/>\nTo prevent  the effect of aliases defined for a word, token or a command, use unalias.<br \/>\n\/home\/viru$ unalias jbin<br \/>\n\/home\/viru$ jbin<br \/>\nJbin:not found<\/p>\n<p>There is another way to accomplish this,that is by using quotes (\u2018\u2019) after a command.the following lines show how.<br \/>\n\/home\/viru$ alias same<br \/>\nalias same=\u2019\/opt\/bin\/samefile.exe\u2019<br \/>\n\/home\/viru$ same \u2018\u2019<br \/>\nsame:not found.<br \/>\nThe effect of alias was nullified for the word same. If you use double quotes after an aliased command name ,(eg: alias df =\u2018df \u2013gt\u2019) then  the actual command will be run.(ie df\u2019\u2019 would run   \/usr\/bin\/df   instead of df  -gt)<\/p>\n<p>Aliases which are defined outside a script or in your .profile do not work inside scripts. so make sure   not to use aliased words in a shell script to contain their actual values  used outside.<\/p>\n<p>df<\/p>\n<p>df<br \/>\ndf command gives you the  information of the disk spaces. It is a very good command for<br \/>\nsystem administration and file system monitoring. You can also view  various parameters<br \/>\nlike total number of files in a particular file system and maximum allocated values.<\/p>\n<p>Reducing the space occupied by a file system helps to boost system performance by making<br \/>\nThe applications and utilities that use these file systems take lesser time for accessing data,<br \/>\nSo constantly running df helps.<\/p>\n<p>Example 1)<br \/>\ndf comes various options like -g,-m,-k etc which helps you to view file system sizes in gigabytes, megabytes or kilobytes blocks  resp , including t gives total allocated space.<\/p>\n<p>Consider the output of df \u2013gt.<\/p>\n<p>\/home\/Prod$ df     \u2013gt.<br \/>\nFilesystem                     GB blocks   Used   Free   Used Mounted on<br \/>\n\/dev\/hd4                            0.75   0.35   0.40    48% \/<br \/>\n\/dev\/hd2                            5.50   3.68   1.82    67% \/usr<br \/>\n\/dev\/hd9var                         4.00   0.63   3.37    16% \/var<br \/>\n\/dev\/hd3                            4.62   0.71   3.91    16% \/tmp<br \/>\n\/dev\/hd1                            8.25   3.96   4.29    48% \/home<br \/>\n\/dev\/hd10opt                        4.50   1.30   3.20    29% \/opt<br \/>\n\/dev\/lv00                           0.12   0.00   0.12     4% \/var\/adm\/csd<br \/>\n\/dev\/fslv00                         5.00   0.03   4.97     1% \/utilities<br \/>\n\/dev\/ora10g_lv                     15.00   5.18   9.82    35% \/ora10g<\/p>\n<p>The output of the command might not look organised in some unix systems.ie: alignment does not seems to be right,<br \/>\nUse awk for help.<\/p>\n<p>\/home\/Prod$ df \u2013gt | awk  &#8216;BEGIN{aa=&#8221;Filesystem&#8221;;bb=&#8221;GB blocks&#8221;;cc=&#8221;Used&#8221;;dd=&#8221;Free&#8221;;ee=&#8221;Used&#8221;;ff=&#8221;Mounted on&#8221;;printf(&#8220;%-40s %9s %6s %6s %6s %-11s\\n&#8221;,aa,bb,cc,dd,ee,ff);} {if($1!=&#8221;Filesystem&#8221;){printf(&#8220;%-40s %9s %6s %6s %6s %-9s\\n&#8221;,$1,$2,$3,$4,$5,$6) } }&#8217;<\/p>\n<p>Filesystem               GB blocks         Used           Free         Used           Mounted on<br \/>\n\/dev\/hd4                      0.75               0.35           0.40          48%           \/<br \/>\n\/dev\/hd2                      5.50               3.68           1.82          67%          \/usr<br \/>\n\/dev\/hd9var                4.00                0.63           3.37         16%          \/var<br \/>\n\/dev\/hd3                      4.62               0.71           3.91          16%         \/tmp<br \/>\n\/dev\/hd10opt             4.50               1.30           3.20          29%        \/opt<br \/>\n\/dev\/lv00                     0.12               0.00            0.12          4%          \/var\/adm\/csd<br \/>\n\/dev\/fslv00                  5.00               0.03           4.97          1 %         \/utilitie\/dev\/hd1<br \/>\n\/dev\/hd1                      8.25               3.96           4.29          48%        \/home<br \/>\n\/dev\/ora10g_lv          15.00             5.18           9.82          35%        \/ora10g<\/p>\n<p>Now ,that seems to be a much better organised output. Use this in a script and keep an<br \/>\nalias for df command to this script named df.<\/p>\n<p>Example 2)<br \/>\nTo constantly monitor disk space you can make a script and run it constantly.<br \/>\n\/home\/Prod$ cat  disk-monitor.sh<br \/>\n#!\/usr\/bin\/ksh<br \/>\nfor   Pspace  in  `df   -gt  | awk  \u2018{ print $4}\u2019  | grep \u2013v   -e used   -e  \/ora  |  tr  -d  \u2018%\u2019 `<br \/>\ndo<br \/>\nif  [  $ Pspace   -gt    80  ]<br \/>\nthen<br \/>\nalarmfunc                  #call the alarm function.<br \/>\nfi<br \/>\ndone<\/p>\n<p>Example 3)<br \/>\n df is also helpful in knowing  number of files present in a mount  point.<br \/>\nIt is also referred to as Inode. For all all the file system mount points  there is a<br \/>\nInode value assigned which gives the maximum  number of files that can be placed in the file system. When the number of files exceed too a large value, you get  \u2018parameter list is too long\u2019<br \/>\nerror with commands that use wildcards as  arguments to filename.<\/p>\n<p>Every file has  an inode value of 1 and a directory has  an inode value of 2.<\/p>\n<p>To see the Inode values along with other attributes,use df  \u2013i, and off course with  awk filtering.(Use different values before  %s for proper alignment)<\/p>\n<p> \/home\/Prod$ df  -i<br \/>\nFilesystem  512-blocks             Free            %Used      Iused        %Iused     Mounted on<br \/>\n\/dev\/hd0    19368                     9976            48%          4714            5%             \/<br \/>\n\/dev\/hd1    24212                     4808            80%          5031            19%        \/usr<br \/>\n\/dev\/hd2     9744                        9352            4%           1900            4%         \/site<br \/>\n\/dev\/hd3     3868                       3856            0%            986              0%          \/tmp<br \/>\n \/dev\/hd1    56890                     23409          41%         2345           40%        \/home        <\/p>\n<p>wc<\/p>\n<p>wc<br \/>\nwc is a very useful utility which can count lines, characters, words, bytes etc in a plain text file<br \/>\nor standard input. In shell scripts, It helps to  store a value for the total lines of a file or output of<br \/>\na command  into a variable for subsequent use. The examples below  show how these things can be achieved.<\/p>\n<p>Example 1)<br \/>\nTo  get  the counts of lines,  words  and  bytes of a file  use wc as follows.<\/p>\n<p>\/home\/mark$ wc    Bulk-SMS-file.txt<br \/>\n 45      140      990&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;> No   of   bytes<br \/>\n |              |&#8212;&#8212;&#8212;->  No  of  Words<br \/>\nNo of lines                                                   <\/p>\n<p> The individual values can be retrieved as field through awk , but wc provides options.<\/p>\n<p>wc   -l      :   Total   Lines<\/p>\n<p>wc   -w    :   Total   words<\/p>\n<p>wc    -c     :  Total   bytes<\/p>\n<p>wc   -k     :  Total   characters<\/p>\n<p>The wc  command considers a word to be a string of characters of non-zero length which are delimited by a white space and  lines are counted when  newline characters occur.<\/p>\n<p>Example 2)<br \/>\nUsing  wc  on multiple files.<\/p>\n<p>\/home\/mark$ ls  file_list-201111*<br \/>\nfile_list-20111105.txt<br \/>\nfile_list-20111113.txt<br \/>\nfile_list-20111120.txt<br \/>\nfile_list-20111128.txt<\/p>\n<p>  \/home\/mark$ wc   -l    file_list-201111*<br \/>\n  98164   file_list-20111105.txt<br \/>\n  531665 file_list-20111113.txt<br \/>\n  527303 file_list-20111120.txt<br \/>\n  564207 file_list-20111128.txt<br \/>\n 1721339 total<\/p>\n<p>This  gives  you the  no of lines  in  every file as well as the sum of  all the individual  line counts.<\/p>\n<p>Same command  can be  run without the  -l option to get the counts of various parameters and their totals.<\/p>\n<p>Example 3)<br \/>\nwc   can also count these  values  from standard  output through pipes.<\/p>\n<p>\/home\/mark$ echo  &#8220;I  Love  You&#8221; | wc<br \/>\n      1       3      17<\/p>\n<p>Hmm!   wc  achieved  something cool  this time\u2026<\/p>\n<p>Similarly you can use wc  -l  as an alternative to grep  -c.<br \/>\n\/home\/mark$  grep  \u2013c   tremendous    Director-speech.txt <\/p>\n<p>Is same as<\/p>\n<p>\/home\/mark$ grep   tremendous    Director-speech.txt  | wc  -l <\/p>\n<p>Example 4)<br \/>\nwc  -l   may consume a lot of time on counting  the line numbers when the size of the file is huge.<br \/>\nIf  we are sure that every line in a file  contains equal number of characters, there  is a faster method to achieve it.<\/p>\n<p>Assume that  you have a continuous file, i.e. a file which  has same number of characters (or bytes ) in each line.<br \/>\n\/home\/mark$  ls   -lrt   All_Customers.lst<br \/>\n-rw-r&#8211;r&#8211;    1 mark   Administ    1321655460912 Dec  16 14:37 All_Customers.lst<\/p>\n<p>\/home\/mark$  wc   -l   All_Customers.lst<br \/>\n23456898<\/p>\n<p>The following steps explain the method.<\/p>\n<p>Step1)<br \/>\nsave the  first thousand lines of the file in a separate  file.<br \/>\n\/home\/mark$  head   -1000   All_Customers.lst   > All_Customers_1000.lst`<\/p>\n<p>Step2)<br \/>\nget  the ratio of  the  total size of the file to the  line count(1000) of the file.<br \/>\n\/home\/mark$  ls  -lrt  All_Customers_1000.lst<br \/>\n-rw-r&#8211;r&#8211;    1 mark   Administ    56344000 Dec  16 14:37 All_Customers.lst<\/p>\n<p>\/home\/mark$  fsize=` ls  -lrt  All_Customers_1000.lst | awk  \u2018{ print  $5}\u2019`<br \/>\n\/home\/mark$  fratio=`expr   $fsize  \/  1000`<br \/>\n\/home\/mark$  echo  $fratio<br \/>\n56344<\/p>\n<p>Now ,fratio actually stores the number of bytes per file.<\/p>\n<p>Step3)<br \/>\nNow divide  the total size of  All_Customers.lst with  fratio.<br \/>\n\/home\/mark$tot_lines=` expr  1321655460912 \/  $fsize`<br \/>\n\/home\/mark$echo  $tot_lines<br \/>\n23456898<\/p>\n<p>Which is same as calculated by wc  -l.<br \/>\nAll These steps can be used in a shell script  for any given file of this type.<\/p>\n<p>If   there are multiple files of such types (such  as file_list-201111*)  and all have the same fratio.(defined above),then  you can  write a script to get the similar output  as that of<br \/>\n wc  \u2013l   file_list-201111*<\/p>\n<p>The script is as shown.<br \/>\nfratio=313<br \/>\ntot_val=0<br \/>\nfor stream in `ls file_list-201111*`<br \/>\ndo<br \/>\nstr=`ls -lrt $stream|awk &#8216;{print  $5 &#8221; + &#8220;}&#8217;|tr -d &#8220;\\n&#8221;|sed &#8216;s\/$\/0\/&#8217;`<br \/>\nval=`echo &#8220;($str)\/$fratio&#8221;|bc`<br \/>\necho  \u201c$val  $stream &#8221;<br \/>\ntot_val=`expr $tot_val + $val`<br \/>\ndone<br \/>\necho  &#8221; $tot_val   total &#8221; <\/p>\n<p>Here ,between the output  of ls  giving sizes of all the files ,a \u2018 +\u2019  symbol  is placed and 0 at the end and is passed to bc command as an expression whose value (the sum)  is divided by the<br \/>\nratio  just as explained in the 3 steps above.<\/p>\n<p>tail<\/p>\n<p>tail<\/p>\n<p>tail command is one of my favourite commands because of  its  usefulness  in viewing the last few lines of a required file and also what is being written into a file ( using \u2013f option).it can also be used to see the progress of cp, mv, tar and other commands.<\/p>\n<p>tail by default shows last ten lines of a file.it can be made to view any last \u2018n\u2019 lines where n is a number<\/p>\n<p>Example 1)<br \/>\nto view the last 1000 lines of a huge  script page wise ,<br \/>\n\/home\/k109$ tail -1000 valuefind.sh | pg<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;..<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; #lines of scripts<br \/>\n&#8230;&#8230;&#8230;..<br \/>\n.<br \/>\n.<br \/>\n.<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;..<br \/>\nStandard input      <--- #here pg waits and asks for you to enter a key before which it displays the next page. This is helpful in analysing a script or debugging it page wise.\n\n\nExample 2)\nTo view the file contents while it is being written, use \u2013f option. If an application is writing continuously into a file and to know what is being written, this option can be used.\nOne disadvantage of this command is however that it cannot be used inside scripts because once\nThe application stops writing to a file the command does not come out of tail directly  and requires some signal like stop or kill to come out.\n\n    Suppose a file is being written by cp command, you can use tail \u2013f  <destination file> to know<br \/>\nexactly what is being written.<\/p>\n<p>Example 3)<br \/>\nTo view the contents of the file starting from a particular line, use  tail + <number>  <file1><br \/>\nSuppose you have a file  worldsport.txt<\/p>\n<p>\/home\/k109$cat  worldsport.txt<br \/>\nThe game is played on a rectangular field of grass or green artificial turf, with a goal in the middle of each of the short ends. The object of the game is to score by driving the ball into the opposing goal. In general play, the goalkeepers are the only players allowed to touch the ball with their hands or arms, while the field players typically use their feet to kick the ball into position, occasionally using their torso or head to intercept a ball in midair. The team that scores the most goals by the end of the match wins. If the score is tied at the end of the game, either adraw is declared or the game goes into extra time and\/or a penalty shootout, depending on the format of the competition.<\/p>\n<p>If it is required to view the file starting from second line,use<\/p>\n<p>\/home\/k109$tail  +2  worldsport.txt<br \/>\nshort ends. The object of the game is to score by driving the ball into the opposing goal. In general play, the goalkeepers are the only players allowed to touch the ball with their hands or arms, while the field players typically use their feet to kick the ball into position, occasionally using their torso or head to intercept a ball in midair. The team that scores the most goals by the end of the match wins. If the score is tied at the end of the game, either adraw is declared or the game goes into extra time and\/or a penalty shootout, depending on the format of the competition.<\/p>\n<p>sort<\/p>\n<p>sort<br \/>\nSort ,  as the name suggests sorts  a file  or output of a command. Various  options  determine the sort criteria  which are called as sort keys. If multiple files are passed as parameters to sort the output of sort is concatenated.<br \/>\nSorting is done in ascending lexicographic order , I e the way in which it appears in a dictionary. If a file contains numbers and alphabet both,  by default sort  places  the  sorted alphabets  first and then the numbers.<\/p>\n<p>Example1)<br \/>\nConsider a file containing  values as shown.<\/p>\n<p>\/home\/jones$  cat  flowers.txt<br \/>\nrose<br \/>\nlily<br \/>\ntulip<br \/>\nmarigold<br \/>\nhibiscus<br \/>\nChrysanthemum<br \/>\n\/home\/jones$  sort   flowers.txt<br \/>\nChrysanthemum<br \/>\nhibiscus<br \/>\nlily<br \/>\nmarigold<br \/>\nrose<br \/>\ntulip<\/p>\n<p>If you want to sort it in reverse order ,use<br \/>\n\/home\/jones$ sort   -r  flowers.txt<br \/>\ntulip<br \/>\nrose<br \/>\nmarigold<br \/>\nlily<br \/>\nhibiscus<br \/>\nChrysanthemum<\/p>\n<p>Example2)<br \/>\nIf you want the sort to to be case insensitive sort  \u2013f must be used.<br \/>\n\/home\/jones $  cat  flowers.txt<br \/>\nrose<br \/>\nlily<br \/>\nChrysanthemum<br \/>\ntulip<br \/>\nmarigold<br \/>\nRose<br \/>\nhibiscus<br \/>\nchrysanthemum<\/p>\n<p>To   default sort(without any option) would give<br \/>\n\/home\/jones $ Sort  flowers.txt<br \/>\nChrysanthemum<br \/>\nRose<br \/>\nChrysanthemum<br \/>\nhibiscus<br \/>\nlily<br \/>\nmarigold<br \/>\nrose<br \/>\ntulip<\/p>\n<p>Here it sorted the letters starting with uppercase first and then  sorted  lower case ones, Now  use sort -f<br \/>\n\/home\/jones $ sort  \u2013f  flowers.txt<br \/>\nChrysanthemum<br \/>\nchrysanthemum<br \/>\nhibiscus<br \/>\nlily<br \/>\nmarigold<br \/>\nRose<br \/>\nrose<br \/>\ntulip<\/p>\n<p>Example3)<br \/>\nA file may contain duplicate lines, and if you want to remove duplicate files before sorting  , use sort \u2013u<br \/>\n\/home\/jones $ grep   error  cron.log<br \/>\nerror code 45:invalid time<br \/>\nerror code 35:Invalid name<br \/>\nerror code 45:invalid time<br \/>\nerror code 25:Invalid email-id<br \/>\nerror code 25:Invalid email-id<br \/>\nerror code 35 Invalid name<\/p>\n<p>\/home\/jones $ grep   error  cron.log | sort  -u<br \/>\nerror code 25:Invalid email-id<br \/>\nerror code 35:Invalid name<br \/>\nerror code 45:invalid time<\/p>\n<p>Example 4)<br \/>\nYou require to sort based  on  a  particular field  when they are separated by a delimiter.<br \/>\n\/home\/jones $ cat  detailed-list.csv<br \/>\ndolphin|mammal|12<br \/>\ngiraffe|mammal|7<br \/>\nkingfisher|aves|3<br \/>\nmoth|insecta|1<br \/>\nshark|fish|6<br \/>\nviper|reptile|2<\/p>\n<p>Now,  The output of default sort command is<br \/>\ndolphin|mammal|12<br \/>\ngiraffe|mammal|7<br \/>\nkingfisher|aves|3<br \/>\nmoth|insecta|1<\/p>\n<p>shark|fish|6<br \/>\nviper|reptile|2<br \/>\nit sorted on the basis of first field (separated by \u2018|\u2019) in alphabetic order. For a change, you required to sort it based on another column.<br \/>\n\/home\/jones$ sort  -t   \u201c|\u201d  +1  detailed-list.csv<br \/>\nkingfisher|aves|3<br \/>\nshark|fish|6<br \/>\nmoth|insecta|1<br \/>\ndolphin|mammal|12<br \/>\ngiraffe|mammal|7<br \/>\nviper|reptile|2<\/p>\n<p>Here  -t  \u201c|\u201d  tells the sort command  do sorting on  fields  delimited by a   \u201c|\u201d character. If you do not use  -t option, sequence of  space  characters is considered as   default delimiter .  \u201c+1\u201d    instructs sort to ignore the first field or sort from second field.<\/p>\n<p>Similarly if you wanted to sort it based on the third column, just using  +2  instead of +1 might not work in the given example. The output of that sort command would be as follows.<\/p>\n<p>\/home\/jones$ sort  -t  \u201c|\u201d  +2  detailed-list.csv<br \/>\nmoth|insecta|1<br \/>\ndolphin|mammal|12<br \/>\nviper|reptile|2<br \/>\nkingfisher|aves|3<br \/>\nshark|fish|6<br \/>\ngiraffe|mammal|7<br \/>\nIt  sorted the third  column according to its alphabetic value  and not arithmetic value. To do so you must use  -n option<\/p>\n<p>\/home\/jones$ sort   -n  -t  \u201c|\u201d  +2  detailed-list.csv<br \/>\nmoth|insecta|1<br \/>\nviper|reptile|2<br \/>\nkingfisher|aves|3<br \/>\nshark|fish|6<br \/>\ngiraffe|mammal|7<br \/>\ndolphin|mammal|12<\/p>\n<p>Example5)<br \/>\nThe  sorting based on fields can be achieved using   sort with \u2013k option. consider a file containing numbers.<br \/>\n\/home\/jones$ cat  num-luck<br \/>\n6758 987 456<br \/>\n2586 324 934<br \/>\n0437 235 417<br \/>\n2586 324 934<\/p>\n<p>Suppose  you wanted to sort  this list  such that sorting should start from 3rd column of 1st field and 4th column of  1st  field. Here fields are separated by  one or more spaces.  Columns here refer to characters.<\/p>\n<p>\/home\/jones$ sort   -k1.3,1.4   num-luck<br \/>\n2812 624 208<br \/>\n0437 235 417<br \/>\n6758 987 456<br \/>\n2586 324 934<\/p>\n<p>To sort from 2nd column of 1st field and  3rd  column of second field in reverse order,<\/p>\n<p>\/home\/jones$ sort   -k1.2,2.3r   num-luck<br \/>\n2812 624 208<br \/>\n6758 987 456<br \/>\n2586 324 934<br \/>\n0437 235 417<\/p>\n<p>Similarly, to  sort lines based on 1st and 3rd fields, use<br \/>\nSort  \u2013k1 \u2013k3  <filename ><\/p>\n<p>Example 6)<br \/>\nYou may require to sort a particular file and rewrite the file with the sorted file. A simple  command of the form<br \/>\nSort  filename  >new_sorted_filename     will not work and is dangerous as it  rewrites it into  an empty file. Use  sort with  \u2013o option.<\/p>\n<p>\/home\/jones$ sort  -o   flowers.txt    flowers.txt <\/p>\n<p>The  syntax is  sort  \u2013o  <sorted-file>    <file><\/p>\n<p>Example 7)<br \/>\nSort  uses a lot of temporary space  while sorting huge files. and by default it uses  \/tmp   directory. If sufficient space was not allocated  to \/tmp, then  the command would abort abruptly. so sort provides an option  -T by which you can  use an alternative directory  for storing temporary files.<\/p>\n<p>The sort command  sort  -t   \u201c|\u201d  +1  detailed-list.csv in example 4 can be written as<br \/>\nsort  -t   \u201c|\u201d  +1   -T   \/backup\/jones     detailed-list.csv.<br \/>\nthis will use  \/backup\/jones    directory   for storing temporary files.<\/p>\n<p>sed<\/p>\n<p>sed<br \/>\nsed  or stream editor is an editing utility that modifies  lines of a file as specified by an instruction string and writes it to standard output .sed   can thus  perform  the same functions of the commands like tr, grep  and awk ,even though sed has  functionalities and options unique to itself.<br \/>\nThough the applications of sed  are enormous, only some of the important uses of the command  are discussed here with examples.<br \/>\nExample 1)<br \/>\nIt is required to you to print the contents of a file  starting from a particular line number  and  ending into  another ,use sed as follows.<br \/>\n\/home\/UAT$  sed   -n   \u201835,46p\u2019  general-dates.prt<br \/>\nThis  command prints  the contents of the file  \u201cgeneral-dates.prt \u201c  starting from  its 35th line to the  46th.<br \/>\nTo print  only the  35th line of a file use<br \/>\n\/home\/UAT$  sed   -n   \u201835p\u2019  general-dates.prt<br \/>\nMore examples<br \/>\n\u00b7         To  print  all the lines of a file starting from  its 1st line to  the last line<br \/>\n       sed   -n   \u20181,$p\u2019  general-dates.prt<br \/>\n\u00b7         To  print  all the lines of a file between  line  numbers  whose  values are stored  in  variables $start-line  and  $end-line .<br \/>\nsed  \u2013n  \u201c${start-line} , ${end-line}p\u201d   general-dates.prt<br \/>\n\u00b7         To  print all the lines of the file except the 5th line<br \/>\nsed    \u20185d\u2019  general-dates.prt<br \/>\n\u00b7         To  print all the lines of the file except those lines  between the  8th  and  the 40th (i.e. 8th line and 40th lines are also not printed).<br \/>\nsed    \u20188,40d\u2019  general-dates.prt<\/p>\n<p>Example2)<br \/>\nsed can also  search for patterns in file or standard input just like grep , but much more sophisticated pattern searches can be done  as shown in  the following examples.<br \/>\n\u00b7         A  grep  command can be implemented using sed as follows<br \/>\nConsider a grep command<br \/>\ngrep   industry  general-dates.prt<br \/>\nalternatively sed can perform  the same using..<br \/>\nsed \u2013n \u2018\/industry\/p\u2019  general-dates.prt<\/p>\n<p>\u00b7         To  print  all the lines of a file between the first occurrences of two patterns<br \/>\n     sed \u2013n \u2018\/industry\/,\/station\/p\u2019   general-dates.prt<\/p>\n<p>This prints all the lines starting from the line which has the first occurrence of  \u2018 industry\u2019 and  the first occurrence of  \u2018station\u2019 .<\/p>\n<p>\u00b7         To print  all the lines of a file  starting from its first line and  the  line of  first occurrence of  \u2018industry\u2019,<br \/>\n       sed \u2013n \u20181,\/ industry\/p\u2019   general-dates.prt<\/p>\n<p>\u00b7         To  put all the lines starting from line with the first occurrence of the pattern \u2018industry\u2019  in the file  to the last line of  the file  into standard output(i.e. print).<\/p>\n<p>sed \u2013n \u2018\/industry\/,$p\u2019   general-dates.prt<\/p>\n<p>\u00b7         To  print all the lines starting from the line containing the  pattern string whose value is stored in  a variable $ptrn  to the 15th line of the file.<\/p>\n<p>sed \u2013n  \u2018\/\u2019$ptrn\u2018\/,15p\u2019  general-dates.prt<\/p>\n<p>The   pattern space can contain   more complex   regular expressions .<\/p>\n<p>Example3)<br \/>\nsed  can  replace the occurrences  of patterns  into a new one from  a file and put it to standard output.<br \/>\n\u00b7         To  replace  the first occurrence of   \u2018teacher\u2019   with  \u2018tutor\u2019  in the file  groupsList.xml<br \/>\nsed  \u2018s\/ teacher\/ tutor\/\u2019  groupsList.xml<br \/>\n\u00b7         To replace all the occurrences of   \u2018teacher\u2019   with  \u2018tutor\u2019  in the file  groupsList.xml<br \/>\nsed   \u2018s\/ teacher\/ tutor\/g\u2019  groupsList.xml<br \/>\nhere  g -> represents  global.<br \/>\n\u00b7         To replace all the occurrences of   a string stored in a variable  ${string_pattern}  to  ${replace_string}   in a file.<br \/>\nsed   \u2018s\/\u2019${string_pattern}\u2019\/\u2019 ${replace_string}\u2019\/g\u2019  groupsList.xml<\/p>\n<p>\u00b7         To  add a  \u201c,\u201d   character  between  the  original pattern  and  replacement string   defined by ${string_pattern}\u2019   and  ${replace_string}  respectively  .<br \/>\nsed   \u2018s\/\u2019${string_pattern}\u2019\/&#038;,\u2019${ replace_string }\u2019\/g\u2019  groupsList.xml<br \/>\nthe single quotes enclosing the variable is a necessary.<br \/>\n&#038;  variable stores the matched pattern when the string  stored in ${string_pattern} is a regular expression.<\/p>\n<p>Example 4)<br \/>\nSed can be used to edit a particular line of the file. amazing..isnt it..?<br \/>\n\/home\/UAT$ cat dir_struct<br \/>\n1.       35467       vdn          \/home\/vd2<br \/>\n2.       46788       ghi        \/var\/gh1\/gh<br \/>\n3.       89078       bjk       \/home\/vd2<br \/>\n4.       56890       lod          \/home\/lod\/inter<br \/>\n5.       33456       bhj       \/home\/bhind<br \/>\n6.       45790       krk       \/myhome\/krk<\/p>\n<p>Now if I want to change the  directory structure on line number 4 from \/home to \/var, sed can be used as follows.<\/p>\n<p>\/home\/UAT$ sed  \u20184  s\/home\/var\/\u2019  dir_struct<br \/>\n1.       35467       vdn          \/home\/vd2<br \/>\n2.       46788       ghi        \/var\/gh1\/gh<br \/>\n3.       89078       bjk       \/home\/vd2<br \/>\n4.       56890       lod          \/var\/lod\/inter<br \/>\n5.       33456       bhj       \/home\/bhind<br \/>\n6.       45790       krk       \/myhome\/krk<\/p>\n<p>Here we substituted only  home with var in the 4th line .If you need to substitute \/home\/vd2  with \/var\/vd1 , you would have written the command as follows.<br \/>\nsed  \u20184  s\/\\\/home\\\/vd2\/\\\/var\\\/vd1\/\u2019  dir_struct<br \/>\nlooks a little ugly because we used \u2018\/ \u2018 as delimiter and to differentiate   the \u2018\/\u2019  in \/home\/vd2 and \/var\/vd1,  a backslash \u201c\\\u201dwas used before it.<br \/>\ninstead of using \u2018\/\u2019as delimiter  other characters  like : ,  |  ,  { ,  # , !  etc  can be used for such scenarios.<br \/>\nThe above sed can be written using # as follows.<\/p>\n<p>sed  \u20184  s#\/home\/vd2#\/var\/vd1#\u2019  dir_struct<\/p>\n<p>Example 5)<br \/>\nYou have many occurrences of a pattern in a line and you want to replace   just the nth pattern  or all  n+1,n+2.. occurrences . use  a number after  the ending \u201c\/\u201d.<br \/>\n\/home\/jade$ echo &#8220;1st 2nd 3rd 4th 5th 6th&#8221;|sed &#8220;s\/[0-9]th\/\/2&#8221;<br \/>\n1st 2nd 3rd 4th  6th                                #  |&#8212;&#8211;second occurrence of [0-9]th<\/p>\n<p>The command above replaced only the 2nd occurrence of a digit followed by \u201cth\u201d.<br \/>\nIf you need to replace all occurrences starting from 2nd,then use the following command.<\/p>\n<p>\/home\/jade$ echo &#8220;1st 2nd 3rd 4th 5th 6th&#8221;|sed &#8220;s\/[0-9]th\/\/2g&#8221;<br \/>\n&#8220;1st 2nd 3rd 4th  &#8221;<\/p>\n<p>rsh<\/p>\n<p>rsh<\/p>\n<p>rsh  is used to execute commands on a remote machine.<br \/>\nThe rsh command  executes the   command or a program in another host from current working  machine without having to login into that remote machine  by entering a password as in ssh. You can run any unix command, or a shell script of a remote host.<\/p>\n<p>Prerequisites<br \/>\nrsh command  cannot be executed without making these changes.<\/p>\n<p>1) make a list of the users of both the local and remote hosts  and their  $LOGNAME  s  who  are going to use  rsh  to run commands or scripts.<\/p>\n<p>2)Open the required ports  which is going to be used  for rsh  and rcp.<\/p>\n<p>3)make an entry  of remote host  in  \/etc\/hosts  file  of the local host  and an entry  of local host in \/etc\/hosts of the remote host. This change  can  done my root user,if you do not have root access then contact your  unix admin.<\/p>\n<p>A sample entry is as shown, assume that your hostname is  mahaprana  and the IP address is 158.0.125.23, Then the  remote  host\u2019s  \/etc\/hosts  file  must contain a line<br \/>\n158.0.125.23     mahaprana    #backup server.<\/p>\n<p>the comments (3rd column) is  optional.<br \/>\nSimilarly make an entry of remote host In \/etc\/hosts  file   of local host. If remote hostname is  alpaprana  and  its IP address is 158.0.125.45 .<br \/>\n158.0.125.45  alpaprana<\/p>\n<p>4)The list of users  are  to be placed  in $HOME\/.rhosts  file of both local and remote hosts for every  user.<br \/>\nEg: If  the local users   are  divya and ajay and remote users are  bhaskar and  ajay.<br \/>\n.<br \/>\nMake entries as shown for respective users in local host<br \/>\n\/home\/ divya$ hostname<br \/>\nmahaprana<br \/>\n\/home\/ divya$ echo  $HOME<br \/>\n\/home\/ divya<br \/>\n\/home\/ divya$ cat  .rhosts<br \/>\n158.0.125.45   bhaskar<br \/>\n158.0.125.45    ajay<\/p>\n<p>\/home\/ajay$echo $HOME<br \/>\n\/home\/ajay<br \/>\n\/home\/ ajay$ cat  .rhosts<br \/>\n158.0.125.45   bhaskar<br \/>\n158.0.125.45    ajay<\/p>\n<p>And  entries  shown below   in  the remote host.<\/p>\n<p>\/home\/ajay$hostname<br \/>\nalpaprana<br \/>\n\/home\/ ajay$ cat  $HOME\/.rhosts<br \/>\n158.0.125.23  ajay<br \/>\n158.0.125.23  divya<\/p>\n<p>\/home\/bhaskar\/ cat  $HOME\/.rhosts<br \/>\n158.0.125.23  ajay<br \/>\n158.0.125.23  divya<\/p>\n<p>After these changes are made, you can run the rsh command as shown in following examples.<\/p>\n<p>Example 1)<br \/>\nSuppose you are working  as a user  in local host  and  the local and remote users are same.<br \/>\n\/home\/ ajay$ echo  $LOGNAME<br \/>\najay<br \/>\n\/home\/ ajay$ rsh   158.0.125.45  \u201cls   inter*\u201d<br \/>\ninterbranch.csv.gz<br \/>\ninterschool.csv.gz<br \/>\ninter _college.txt<br \/>\ninter-dept.lst<\/p>\n<p>This runs the command  \u2018ls  inter* \u2018  in the remote host  158.0.125.45 as user  ajay.<br \/>\nBy default  it  runs  the   commands within double quotes  in user (ajay ) \u2018s home directory defined by the  $HOME variable.<\/p>\n<p>Example 2)<br \/>\nTo run the commands   or process of a different   remote user<\/p>\n<p>\/home\/ divya$ rsh    158.0.125.45  -l   bhaskar  \u201c grep   -i  beatles  Albumlist\/old\/Film    \u201d<br \/>\nHere comes the sun  &#8211; BEATLES<br \/>\nBeatles-Twist and  shout<\/p>\n<p>To run multiple commands in the remote host use semicolon to separate them.<br \/>\nEg: If you want to run the  above command by making your working directory  as Albumlist\/old<br \/>\nrsh    158.0.125.45  -l   bhaskar  \u201c cd  Albumlist\/old;  grep  -i  beatles  Film\u201d .<br \/>\nExample 3)<br \/>\nyou cannot use the environmental variables of the remote user directly inside rsh. For initializing all those variables run .profile<\/p>\n<p>\/home\/ ajay$ rsh   158.0.125.45  -l   bhaskar   \u201c echo  $ORACLE_HOME; sqlplus \/\u201d<br \/>\nksh: sqlplus  not found<br \/>\n this did not work.<br \/>\n\/home\/ ajay$ rsh   158.0.125.45  -l   bhaskar   \u201c. $HOME\/.profile  1> \/dev\/null; echo  $ORACLE_HOME; sqlplus \/\u201d<br \/>\n\/oracle\/app\/product<br \/>\nSQL><br \/>\n\/dev\/null redirects  the standard output of running .profile to \/dev\/null.<\/p>\n<p>rm<\/p>\n<p>rm<\/p>\n<p>rm  is used to remove files or directories. It can be  used interactively to ask user input while removing  multiple files or  the contents of a  directory.<\/p>\n<p>A great care has to be taken before running rm command. There is no way to recover the files which are removed unless they were backed up on tape.<\/p>\n<p>Use rm <filename> to remove these files.<\/p>\n<p>Example 1)<br \/>\nTo remove multiple files with a common keyword.<\/p>\n<p>\/home\/jenny$ls   city_DETAIL*.lst<br \/>\nCity_DETAIL_MUM.lst<br \/>\nCity_DETAIL_DEL.lst<br \/>\nCity_DETAIL_BLR.lst<br \/>\nCity_DETAIL_KOL.lst<br \/>\nCity_DETAIL-ALL<br \/>\n..<br \/>\nTo remove all these files except  City_DETAIL-ALL   enter<br \/>\n\/home\/jenny$rm  City_DETAIL_???.lst<\/p>\n<p>If the  file does not belong to the current user, or if the file does not have write permissions, the<br \/>\nrm command asks you before removing ,i:e<\/p>\n<p>rm: remove City_DETAIL_KOL.lst??.lst<\/p>\n<p>If you do not want to answer to  this  question to all the files, use \u2013f option to remove forcefully.<\/p>\n<p>rm  -f  City_DETAIL_???.lst<\/p>\n<p>Example 2)<br \/>\nTo remove directories and files use \u2013rf option<br \/>\n\/home\/jenny$rm  -rf   FILMS<br \/>\nThis will remove all the  sub directories of  and the directory itself. This command is also same as<br \/>\ncd  \/; rm \u2013rf  home\/jenny\/FILMS<\/p>\n<p>remember that you cannot remove a directory  if  it  is  the  path of  your working directory or a parent when you are inside its subdirectories.<br \/>\neg: both of these  don\u2019t work.<\/p>\n<p>\/home\/jenny \/FILMS$ rm   -rf    \/home\/jenny \/FILMS             #Does not work<br \/>\n\/home\/jenny \/FILMS\/K3g$rm   -rf   \/home\/jenny \/FILMS   #Does not work<\/p>\n<p>To view the files which are being removed when files are removed in bulk.<\/p>\n<p>Suppose you have a file containing the list of files to be removed. then<br \/>\n\/home\/jenny$ head file_to_remove_list<br \/>\nJj12_2.txt<br \/>\nDf003.log<br \/>\nAwer_cat.lst<br \/>\nSdifre.post<br \/>\nMail34.log<br \/>\nTAB\/Hourwise_list.doc<br \/>\nSequence.log<br \/>\nCreated\/Sqlldr.bad<br \/>\nOLD_FILE\/Jenny_old.log<br \/>\nHearts_jai.mkv<\/p>\n<p>home\/jenny$sed  \u2018s\/^\/rm  -ef  \/g\u2019  file_to_remove_list  > file_to_remove_list.sh<br \/>\nhome\/jenny$chmod  +x   file_to_remove_list.sh<br \/>\n\/home\/jenny$.\/ file_to_remove_list.sh<br \/>\nremoving Jj12_2.txt<br \/>\nremoving Df003.log<br \/>\nremoving Awer_cat.lst<br \/>\nremoving Sdifre.post<br \/>\nremoving Mail34.log<br \/>\nremoving TAB\/Hourwise_list.doc<br \/>\nremoving Sequence.log<br \/>\nremoving Created\/Sqlldr.bad<br \/>\nremoving OLD_FILE\/Jenny_old.log<br \/>\nremoving Hearts_jai.mkv<br \/>\n\/home\/jenny$<\/p>\n<p>Example 4)<br \/>\nTo remove  files interactively use  -i option.<br \/>\n\/home\/jenny$ rm    -ir   FILMS<br \/>\nrm: remove  FILMS\/ Schindler&#8217;s List ?y<br \/>\nrm: remove  FILMS\/ Chinatown? y<br \/>\nrm: remove  FILMS\/ Taxi Driver?y<br \/>\nrm: remove  FILMS\/ The Sixth Sense?n<br \/>\n\/home\/jenny$<\/p>\n<p>y  and n are inputs given by you to remove or  not to  remove resp.<\/p>\n<p>rcp<\/p>\n<p>rcp<br \/>\nrcp is used to copy or send files or directories between two hosts. It can be used an alternative to ftp  and related protocols like sftp, but no password is required to send files unlike ftp.<br \/>\nFor rcp to work,  various  prerequisites are required ,which  are same for the  rsh command.(refer rsh)<\/p>\n<p>Assume  your  hostname is  Prod-serv  and IP is 192.158.0.140  and the remote hostname is<br \/>\nTest-serv and IP is 192.158.0.120 .The local user is kumar and remote user is  warren  in all of the examples.<\/p>\n<p>Example 1)<br \/>\nTo send a file  from a  local host to remote host.<\/p>\n<p>\/home\/kumar$ rcp   Audit_document.txt    warren@192.158.0.120:<\/p>\n<p>This sends the local file    Audit_document.txt  to the host  Test-serv  (you can use Test-serv  in place of  the IP address)  and places it in the $HOME directory of  warren.<br \/>\nWith the name  Audit_document.txt and owner of the file  as  warren.<\/p>\n<p>Example 2)<br \/>\nTo receive   a file from remote host to local  host.<br \/>\n\/home\/kumar$ rcp    warren@192.158.0.120:global\/Meal_pass2.prt   .<br \/>\nThis  copies the file  Meal_pass2.prt  in \/home\/warren\/global  directory of  192.158.0.120<br \/>\nto the current directory (\/home\/kumar  denoted here  by   \u2018.\u2019  or dot).<\/p>\n<p>rcp  just like cp changes the modification time(time stamp) of the destination file to the latest time. To retain the same time stamp  use  rcp \u2013p . The  above example can be written as<\/p>\n<p>rcp  -p  warren@192.158.0.120:global\/Meal_pass2.prt   .<\/p>\n<p>Example 3)<br \/>\nTo copy directories  between hosts  use rcp  with \u2013r option.<\/p>\n<p>\/home\/kumar$ ls  -ld  localdir<br \/>\ndrwxr-xr-x    2  kumar   tools        256  Jul 14  2009  localdir<\/p>\n<p>\/home\/kumar$rcp   -r  localdir   warren@192.15.0.120:<br \/>\nThis copies  the entire directory localdir(its sub directories)  to  $HOME directory of  warren@192.15.0.120.<\/p>\n<p>More examples:<br \/>\nTo  copy  two files  booked_ticket1.txt  , booked_ticket2.txt   to \/var\/docs directory of  192.15.0.120<br \/>\nrcp    booked_ticket.txt   booked_ticket2.txt   warren@192.15.0.120: \/var\/docs<br \/>\nor<br \/>\nrcp  booked_ticket?.txt    warren@192.15.0.120: \/var\/docs<\/p>\n<p>To  copy  the file  \u2018pattern-styles.tar.gz\u2019    to    \/home\/warren\/images  directory of  192.15.0.120  as  style1.tar.gz with same  time stamp.<br \/>\nrcp    -p    pattern-styles.tar.gz    warren@192.15.0.120: images\/style1.tar.gz<\/p>\n<p>ps<\/p>\n<p>ps<br \/>\nps   displays  all the processes  in a unix   system. every command, script or an application is considered as a process in unix. All the processes run until the command or application is completed or stopped. Each process has a unique process id ( PID)<br \/>\nIt has the same output of windows tasklist command.<br \/>\nExample 1)<br \/>\nto list  only your processes  (i:e all the commands , and applications run in current  session )<br \/>\n\/home\/priya$ ps<br \/>\n   PID       TTY      TIME   CMD<br \/>\n  217140  pts\/2  0:00 -ksh<br \/>\n  594062  pts\/2  0:00 -ksh<br \/>\n  652138  pts\/2  2:03  java   webfile.java<br \/>\n  820120  pts\/2  0:00  ps<\/p>\n<p>Example 2)<br \/>\nTo  list  all  the processes running  in  the server  page wise , use \u2013ef option<br \/>\n\/home\/priya$  ps  -ef  | pg<br \/>\n UID     PID       PPID C    STIME    TTY  TIME   CMD<br \/>\npriya  184434       1  24 05:32:34      &#8211;  0:50 java  \/usr\/bin\/java\/start-web.java<br \/>\nroot   213146       1   0 05:32:31      &#8211;  1:21 java  \/usr\/bin\/dsmc<br \/>\nmatt   327814  893836   0 12:28:09      &#8211;  0:00 sleep 120<br \/>\nroot   352266       1   0 05:32:38      &#8211;  0:14 java  \/usr\/bin\/ftpd<br \/>\npriya  368734       1   0 05:32:42      &#8211;  0:07<br \/>\npriya  372912       1   0 05:32:43      &#8211;  0:10 java  \/usr\/bin\/java\/start-web3.java<br \/>\nscripts 409806       1  0 05:32:39      &#8211;  0:13 java  \/usr\/bin\/java\/start-web2.java -d final -f clear<br \/>\nscripts  418030       1   0 05:32:35      &#8211;  1:08 java  \/usr\/bin\/java\/start-web.java -d final -f clear<br \/>\nscripts  430084       1   0 05:32:23      &#8211;  0:02 \/usr\/bin\/perl -w getfile.cgi<br \/>\nscripts  442592  430084   0 12:17:38      &#8211;  0:00 sleep 900<br \/>\nscripts  454810       1   3 05:32:29      &#8211;  1:42 java  \/usr\/bin\/java\/start-web.java -d final -f clear<br \/>\nstandard input<\/p>\n<p>Example 3)<br \/>\nTo list all the processes which are run by an user,<br \/>\n\/home\/priya$  ps  -fu   matt<br \/>\nUID     PID    PPID   C    STIME     TTY    TIME CMD<br \/>\nmatt  174431       1  24 05:32:34      &#8211;        0:50 wc -l<br \/>\nmatt  723156       1   0    05:32:31     pts\/2 1:21 cat items<br \/>\nmatt  327814  893836   0 12:28:09      &#8211;   0:00 sleep 120<br \/>\nmatt    1566          1   0 0 5:32:38  pts\/1    0:14 sed \u2018s\/sim\/\/\u2019<br \/>\nmatt  668739       1   0 05:32:42      &#8211;          0:07 \/usr\/bin\/perl<br \/>\nmatt  352912       1   0 05:32:43      &#8211;          0:10 java hello.java<\/p>\n<p>All your processes and  the processes  of other users can be viewed.<\/p>\n<p>In the output of the command above ,the various column heads are defined as follows.<br \/>\nPID<br \/>\nThe process ID of the process.<\/p>\n<p>UID<br \/>\nThe user ID of the process owner. The login name is printed under the -f flag.<\/p>\n<p>PPID<br \/>\nThe process ID of the parent process.<\/p>\n<p>    C<br \/>\nCPU utilization of process or thread, incremented each time the system clock ticks and the process or thread is found to be running. Large values indicate a CPU intensive process and result in lower process priority whereas small values  indicate an I\/O intensive process and result in a more favourable priority.<\/p>\n<p>STIME<br \/>\nThe starting time of the process.<\/p>\n<p>TTY<br \/>\nThe controlling terminal for the process<br \/>\nif There is a \u2018-\u2018 ,it means the  process is not associated with a terminal.<br \/>\nOtherwise indicates The TTY number. For example, the entry pts\/2 indicates terminal 2.<\/p>\n<p>CMD<br \/>\nContains the command name which started the process. The full command name and its parameters are displayed with the -f flag.<\/p>\n<p>paste<\/p>\n<p>paste<br \/>\npaste is an excellent command for text processing, even though its uses are limited. It can mainly be used to append the contents of files. paste is helpful in creating text files by combining<br \/>\nindividual files such that  all the  lines appear on the same row  in the destination file i:e linearly.<\/p>\n<p>Example 1)<br \/>\nYou have two files as shown.<br \/>\n\/users\/higgs$ cat    Start_Times.log<br \/>\nGetname(  )   at   Fri Dec 30 22:29:16 IST 2011<br \/>\nGetip(  )  at   Fri Dec 30 22:30:22 IST 2011<br \/>\nCheckip(  ) at   Fri Dec 30 22:30:23 IST 2011<br \/>\nGetfile(  )    at  Fri Dec 30 22:31:22 IST 2011<\/p>\n<p>\/users\/higgs$ cat   End_Times.log<br \/>\nGetname(  )   at   Fri Dec 30 22:29:17 IST 2011<br \/>\nGetip(  )  at   Fri Dec 30 22:30:28 IST 2011<br \/>\nCheckip(  ) at   Fri Dec 30 22:30:24 IST 2011<br \/>\nGetfile(  )    at  Fri Dec 30 22:31:42IST 2011<\/p>\n<p>If you have to combine these files such that the start and end times of a function appear on a common line, use paste as follows.<\/p>\n<p>\/users\/higgs$paste  Start_Times.log   End_Times.log<br \/>\nGetname(  )    at   Fri Dec 30 22:29:16 IST 2011   Getname(  )   at   Fri Dec 30 22:29:17 IST 2011<br \/>\nGetip(  )   at   Fri Dec 30 22:30:22 IST 2011   Getip(  )  at   Fri Dec 30 22:30:28 IST 2011<br \/>\nCheckip(  )  at   Fri Dec 30 22:30:23 IST 2011  Checkip(  ) at   Fri Dec 30 22:30:24 IST 2011<br \/>\nGetfile(  )    at  Fri Dec 30 22:31:22 IST 2011 Getfile(  )    at  Fri Dec 30 22:31:42IST 2011<\/p>\n<p>Notice that one space was added in between the two  same rows of the two files .This<br \/>\nis    default for paste without any option.<\/p>\n<p>In some cases you may need to  place a different delimiter between lines of the row.<\/p>\n<p>\/users\/higgs$ paste   -d  \u2018,\u2019  Start_Times.log   End_Times.log   >Start_end_times.csv.<br \/>\n\/users\/higgs$ cat   Start_end_times.csv<br \/>\nGetname(  )    at   Fri Dec 30 22:29:16 IST 2011,   Getname(  )   at   Fri Dec 30 22:29:17 IST 2011<br \/>\nGetip(  )   at   Fri Dec 30 22:30:22 IST 2011 ,  Getip(  )  at   Fri Dec 30 22:30:28 IST 2011<br \/>\nCheckip(  )  at   Fri Dec 30 22:30:23 IST 2011 , Checkip(  ) at   Fri Dec 30 22:30:24 IST 2011<br \/>\nGetfile(  )    at  Fri Dec 30 22:31:22 IST 2011 ,Getfile(  )    at  Fri Dec 30 22:31:42IST 2011<\/p>\n<p>Open this file Start_end_times.csv  in windows excel if you want a better view.<\/p>\n<p>Example 2)<br \/>\nIf you want  the contents to appear serially,use paste \u2013s.<\/p>\n<p>Imagine you have two files<br \/>\n\/users\/higgs$ cat   Booked.log<br \/>\nDon2<br \/>\nSherlock_homes<br \/>\nMission_Impossible4<br \/>\nThe_Dirty_picture<\/p>\n<p>\/users\/higgs$cat Showtime.log<br \/>\n10:30<br \/>\n14:20                                            4 spaces after   each line<br \/>\n17:40<br \/>\n22:45      <\/p>\n<p>\/users\/higgs$paste  -s        Booked.log   Showtime.log<\/p>\n<p>Don2       Sherlock_homes      Mission_Impossible4     The_Dirty_picture<br \/>\n10:30                14:20                      17:40                                  22:45<\/p>\n<p>mv<\/p>\n<p>mv<br \/>\nmv  command  moves or renames files  or directories within  the same file system or  between different file systems. you can also do this interactively when you are moving multiple files.mv is similar to doing cut and paste in windows,<\/p>\n<p>Example 1)<br \/>\nTo  rename a file  or a directory.<br \/>\n\/home\/yogi$mv   yog_LIST    jeev_LIST<\/p>\n<p>This renames the file from yog_LIST  to jeev_LIST<br \/>\nSimilarly a directory  can be renamed.   <\/p>\n<p>Example 2)<br \/>\nTo move a file  to a directory.<br \/>\n\/home\/yogi$mv  sqlnet.log    oracle_logs<\/p>\n<p>Here oracle_logs is a directory.if you want to save the log with a different name,enter<br \/>\nmv   sqlnet.log    oracle_logs\/sqlnet_2011.log<br \/>\nIn this case  sqlnet.log is renamed to sqlnet_2011.log and saved in oracle_logs directory.<\/p>\n<p>Example 3)<br \/>\nA file,directory  or a   group of files  or directories can be moved to a<br \/>\ndestination path,<\/p>\n<p>\/home\/yogi$ ls  \u2013lrt   CONSIGNMNENT*<br \/>\n-rw-r&#8211;r&#8211;    1 yogi  Administ           58   Dec   24   00:40    CONSIGNMENT1<br \/>\n-rw-r&#8211;r&#8211;    1 yogi  Administ              6   Dec   24   00:42    CONSIGNMENT2<br \/>\n-rw-r&#8211;r&#8211;    1 yogi  Administ        978    Dec   25   00:59    CONSIGNMENT3                              <\/p>\n<p>CONSIGNMNENT-OLD:<br \/>\n-rw-r&#8211;r&#8211;    1 yogi  Administ           27   Jul   25   01:00    lst2.txt<br \/>\n-rw-r&#8211;r&#8211;    1 yogi  Administ           35   Sep  14   09:00   goods_list<\/p>\n<p>\/home\/yogi$ mv    CONSIGNMNENT*     \/ALL_CONS\/DOCS<\/p>\n<p>This moves all the entities listed above to \/ALL_CONS\/DOCS directory if it exists, otherwise the command gives an error<br \/>\nmv: cannot  rename CONSIGNMENT*  to  \/ALL_CONS\/DOCS, a file or directory in the path does not exist.<\/p>\n<p>Remember that when there are more than 2 arguments to mv , the last argument is considered the destination directory. When there are only 2 arguments, if the 2nd argument contains a  \u2018\u2019\/\u201d  in it, then  the directory structure must exist.<\/p>\n<p>Example 3)<br \/>\nIf you want mv to ask you interactively which files are to be moved, use mv \u2013i.<br \/>\n\/home\/yogi$ mv  -i    Banks_Draft *    DRAFTS\/LIST    <\/p>\n<p>more<\/p>\n<p> more<\/p>\n<p>sometimes, while viewing huge files it would be necessary to view it such that the<br \/>\ncontents of the page are displayed as the user  examines them and wishes to go<br \/>\nto the next one. user can use various keys in order to go front or back of a page. Move<br \/>\nto  few lines  ahead or behind.<\/p>\n<p>Example 1)<br \/>\nsuppose you have a large file with name greenlife.txt. It contains a total of 1000 lines.<\/p>\n<p>Then to open it and view it page wise enter<br \/>\n\/home\/g321$ more  greenlife.txt<br \/>\nsustainable living<br \/>\nSustainable living is a lifestyle that attempts to reduce an individual&#8217;s or soceity\u2019s<br \/>\nattempt to reduce their carbon footprint by altering methods of transportation, energy<br \/>\n sustainability, in natural balance and respectful of humanity&#8217;s symbiotic relaivelyt<br \/>\nly interrelated with the overall principles of sustainable development.<br \/>\nLester R. Brown, a prominent environmentalist and founder of the Worldwatch Inst used<br \/>\n reuse\/recycle economy with a diversified transport system.&#8221;<br \/>\nContents<br \/>\n1 Definition<br \/>\n2 History<br \/>\n3 Shelter<br \/>\n3.1 List of some sustainable materials<br \/>\n4 Power<br \/>\n4.1 List of organic matter than can be burned for fuel<br \/>\n5 Food<br \/>\n5.1 Environmental impacts of industrial agriculture<br \/>\n5.2 Conventional food distribution and long distance transport<br \/>\n5.3 Local and seasonal foods<br \/>\n5.4 Reducing meat consumption<br \/>\n5.5 Organic farming<br \/>\n5.6 Urban gardening<br \/>\n5.7 Food preservation and storage<br \/>\n6 Transportation<br \/>\n7 Water<br \/>\n7.1 Indoor home appliances<br \/>\n7.1.1 Toilets<br \/>\n7.1.2 Showers<br \/>\n7.1.3 Dishwasher\/Sinks<br \/>\n7.1.4 Washing machines<br \/>\n7.2 Outdoor water usage<br \/>\n7.2.1 Conserving Water<br \/>\n7.2.2 Sequestering Water<br \/>\n8 Waste<br \/>\nSustainable living is fundamentally the application of sustainability to lifestyle<br \/>\n&#8212; More (3%) &#8212;<br \/>\nHere it waits for user input to go to the next page. The user now has the choice of doing the following  few things.(many more options available)<br \/>\nto display the next line ,type return or \u201cEnter\u201d key. type f to go<br \/>\nfront 1 line  and b to go back one line.<br \/>\nto display the entire next page type space key.<br \/>\nTo go 100 lines ahead type 100f and press enter<br \/>\nTo go 10 lines behind type  10b<br \/>\n To go to the end of page press shift + g<br \/>\nTo exit press q<br \/>\nTo search a pattern, type \/and enter the keyword.<\/p>\n<p>Example 2)<br \/>\nWhile searching for patterns using more , if you want to ignore cases  use \u2013i option.<br \/>\n\/home\/g321$ more  greenlife.txt<br \/>\n&#8230;<br \/>\n&#8230;.<br \/>\n&#8230;&#8230;                     lines<br \/>\n\/outdoor<br \/>\n|<br \/>\n|<br \/>\n&#8212;&#8212; >This  will search  for all the occurrences of  the pattern \u2018outdoor\u2019 in the file, ignoring case and highlights  them.<\/p>\n<p>Example 3)<br \/>\nYou  can cause  more command to display the specified number of lines in the window  by using \u2013n  number  option.<br \/>\nFor example to view 15 lines per window ,<\/p>\n<p>\/home\/g321$more  -15 greenlife.txt<\/p>\n<p>mkdir<\/p>\n<p>mkdir<br \/>\nmkdir  is used to create  one or more directories. It can create entire directory structure if needed, or can give required permissions to a directory.<\/p>\n<p>Example1)To  simply create a directory or a directory structure.<br \/>\n\/home\/MUM-user$ mkdir  channels<br \/>\nyou further want to create directory structures. The conventional method of doing it would be<br \/>\n\/home\/MUM-user$cd channels<br \/>\n\/home\/MUM-user\/ channels$mkdir  STAR<br \/>\n\/home\/MUM-user\/ channels$mkdir  SONY<br \/>\n\/home\/MUM-user\/ channels$cd SONY<br \/>\n\/home\/MUM-user\/ channels\/ SONY$mkdir  KBC<br \/>\n\u2026.<br \/>\n\u2026..<br \/>\ni:e create all the individual directories in the tree.<br \/>\nmkdir provides an option \u2013p to  help you to avoid  these commands.<\/p>\n<p>\/home\/MUM-user$mkdir  -p  channels\/ STAR\/NGC\/Speed<br \/>\n\/home\/MUM-user$ mkdir  -p  channels\/ SONY\/ KBC<\/p>\n<p>These commands  will  create all the intermediate parent directories and the final directory.<\/p>\n<p>Example 2)<br \/>\nTo change  permissions to directories, you can use chmod command. To  do it while creating them, use  mkdir  -p <permissions>\n<p>\/home\/MUM-user\/ $ mkdir   -p  -m  775   channels\/discovery<br \/>\n\/home\/MUM-user\/ $ls  \u2013ld   channels\/discovery<br \/>\ndrwxrwxr-x 2  MUM-user  Tools      256      NOV 12     22:01 channels\/discovery<\/p>\n<p>man<\/p>\n<p>man<br \/>\nMan command internally invokes the sed command to modify the contents of manual pages(documentation written for the commands) and delivers a user readable output.<br \/>\nExamples:<br \/>\nExample 1:<br \/>\nTo read documentation on sed  command  page-wise<br \/>\n\/home\/b3456\/$ man sed | pg<\/p>\n<p>Example  2:<br \/>\nsuppose that you want to read the entire documentation of all the commands present  in an unix environment and to save all of its  pages in a single text file, you can run the following script from the command line to do so.<br \/>\n\/home\/b3456\/$  cd  \/usr\/bin<br \/>\n\/usr\/bin\/$for   i   in  `ls * `<br \/>\n>do<br \/>\n>man $i  >>\/home\/b3456\/man_all.txt  2>\/dev\/null<br \/>\n>done<br \/>\nNote: \u201c>\u201d symbol comes by default in all the lines<br \/>\nHere 2> indicates standard error.It is redirected to \/dev\/null(which is discarded)<br \/>\nNow you can  take a print out of the text file you have just generated( make full  use of office printer  umm!!) and study all commands at home.<\/p>\n<p>ls<\/p>\n<p>ls<br \/>\nls command is used to list the contents off the directory.ls writes to standard output<br \/>\nall  the information of the files, directories or specifically  of the parameters passed to it.<br \/>\nYou can display these contents in the alphabetically sorted order, or list only particular  files  in<br \/>\nCombination with other command. There are many options with ls which you  may hardly use in normal cases.<br \/>\nHere ,only few frequently used options are discussed.<\/p>\n<p>Example 1)<br \/>\nTo simply display the names of all the files in a directory.<br \/>\n\/home\/script-user$ ls<br \/>\nJoke-and-fun.xt<br \/>\nSend_script.sh<br \/>\nMail-file<br \/>\nRollercoaster<br \/>\nJackson_note.tar<\/p>\n<p>Example  2)<br \/>\nTo display all the files that  have a common  pattern.<br \/>\n\/home\/script-user\/items $ ls table_*.log<br \/>\ntable_111.log<br \/>\ntable_x.log<br \/>\ntable_te1.log<br \/>\ntable_adam.log<\/p>\n<p>Example 3)<br \/>\n To  get a long listing of files which contains all the details such as file size, permissions,<br \/>\nTime stamp, user details sorted by the modification time, use ls as follows.<\/p>\n<p>\/home\/script-user $ ls  \u2013lrt<br \/>\n-rw-r&#8211;r&#8211;    1  script-user  Tools    56344   Dec 16     14:37 Joke-and-fun.xt<br \/>\n-rw-r&#8211;r&#8211;    1  script-user  Tools   105977 Dec 16     15:52  Send_script.sh<br \/>\n drw-r&#8211;r&#8211;  2  script-user  Tools      256      Dec 18      21:01 Mail-file<br \/>\n-rw-r&#8211;r&#8211;    1  script-user  Tools      740      Dec 20      01:03 Rollercoaster<br \/>\n-rw-r&#8211;r&#8211;    1  script-user  Tools       58        Dec 24     00:40 Jackson_note.tar<\/p>\n<p>The first field here shows file permissions, which are discussed in chmod,<br \/>\n2nd field is the type of element,(1 for file 2 for directory..etc)<br \/>\n3rd field gives the owner of the element(file,directory)<br \/>\n4th field gives the group which the user belongs to.<br \/>\n5th field gives the size.<br \/>\n6th,7th and 8th field-modification times.<br \/>\n9 th field gives the name of the element.<\/p>\n<p>You can get any field of the output of ls \u2013lrt using awk.<br \/>\nFor eg: To  get the name of the element from the output of ls \u2013lrt, use awk as follows<br \/>\n\/home\/script-user $ ls  -lrt  |  awk  \u2018{print  $9}\u2019<br \/>\nJoke-and-fun.xt<br \/>\nSend_script.sh<br \/>\n Mail-file<br \/>\nRollercoaster<br \/>\nJackson_note.tar<br \/>\nExample 4)<br \/>\nTo display only the directories in a path, use the output of  ls \u2013lrt  as follows.<br \/>\n\/home\/script-user $ ls  -lrt  |  grep \u201c^d\u201d<br \/>\n drw-r&#8211;r&#8211;  2  script-user  Tools       256      Dec 18      21:01 Mail-file<\/p>\n<p>The  \u2018^\u2019  character represents  a starting character of a line( a \u2018$\u2019 represents end), in fact  it\u2019s not physically seen, but an  interpreted character.<br \/>\nIn  this case grep searched for the  lines starting with  a  \u2018d\u2019 which stands for directories.<\/p>\n<p>Example 5)<br \/>\n you want to list the directories whose name has a common pattern, use ls  \u2013ld  <pattern>\nhome\/script-user\/ebooks $ls   -ld  j*<br \/>\ndrwxr-xr-x    2 script-user  Tools        256      Nov  9 12:10  j2me<br \/>\ndrwxr-xr-x    2 script-user  Tools    20480     Nov  9 12:10  java<br \/>\ndrwxr-xr-x    2 script-user  Tools     4096      Nov  9 12:10  java scripts<\/p>\n<p>Suppose you want to view all the files of the directory  java  use  ls \u2013lrt  java instead of doing  both cd java and ls \u2013lrt.<\/p>\n<p>Example  6)<br \/>\nTo  make  a case insensitive list on a filename parameter, use ls along with grep as follows.<br \/>\nhome\/script-user\/docs$ ls   report*<br \/>\nreport1.doc<br \/>\nreport_eng.doc<br \/>\nreportslist.txt<\/p>\n<p>home\/script-user\/docs$ls  |  grep  \u2013i   report<br \/>\n report1.doc<br \/>\nreport_eng.doc<br \/>\nreportslist.txt<br \/>\nReports_Bulk.wrt<br \/>\nBusiness_reports.doc<\/p>\n<p>The above command is equivalent to  ls  *report*  *Report*   *REPORT*  *Report*\u2026\u2026\u2026..and so on till all the combination of the word report in Ucase and Lcase.<\/p>\n<p>Example 7)<br \/>\nTo  list all the directories in a directory, and its subdirectories, use ls \u2013R<br \/>\nIn this case ls lists all the files inside the directories  starting with j recursively in all its subdirectories.<br \/>\nhome\/script-user\/ebooks $ ls  -R  j*<br \/>\nj2me:<br \/>\nj2me &#8211; the complete reference.pdf  j2me&#8212;the-complete-reference.htm<\/p>\n<p>java:<----------------------------     directory\n java The J2EE Tutorial (Addison Wesley &#038; Sun, 2002).pdf\n(Addison Wesley 2002) - Java Network Programming and Distributed Computing.pdf\n(Ebook) Java - Borland Jbuilder - Developing Database Applications - Inprise.pdf\n(OReilly) Java Network Programming ,2nd Ed.pdf\n(OReilly) Java Server Pages ,2nd Ed.pdf\n\njava scripts:\n\n[Java Script] O'Reilly- JavaScript The Definitive Guide.pdf\n\njava scripts\/newdir:<-------------  subdirectory\n[Java Script] O'Reilly - JavaScript The Definitive Guide 2ed.pdf\n\u2026.\n\u2026.\n\u2026\n^C\n\nExample  8)\nls  by default does not show hidden files and directories. To show hidden files use \u2013a option.\nEg: files like  .profile, .sh_history etc are hidden files. if  have not used \u2013a option you wont be\n able to see these files.\nIn all the directories , there are 2 common hidden directories  .(a dot)  which represents the current directory and  ..( 2 dots) represents the parent of the current directory\n\n\nkill\n\nkill  \nkill is used to send a signal to the process, though the name suggests that it is used only to terminate a process. But, kill  helps to terminate a process more often than not. When some process  is  run unexpectedly or accidentally, it  might have to be aborted ,for which kill helps just like CTRL+ALT+DEL in windows .\n\nExample 1)\nps command gives you the process id s  and other details of various commands, if you want to stop any command, just check the corresponding PID of the  process(the command) which you want to terminate ,then use kill  to stop that process.\n\nConsider the output of ps,\n\n\/home\/b6789$ps  -fu  b6789\nUID  PID  PPID C STIME   TTY TIME  CMD\nb6789   352266      1     0 05:32:38     -  0:14 java  \/usr\/bin\/wc  \u2013l   \nb6789   368734      1     0 05:32:42     -  0:07 [wc]\n------b6789   372912     120 0 05:32:43      -  5:10 java  \/usr\/bin\/java\/dev2.java            \nb6789   409806      1     0 05:32:39     -  0:13 java  \/usr\/bin\/java\/start-atm.java\n\n                                                                                          this process is consuming cpu and has to be terminated,\n\n\/home\/b6789$kill  372912\nThis sends the signal SIGTERM to the process 372912, and terminates it.\nSometimes the process may refuse to terminate just by SIGTERM, in that case  use SIGKILL signal(kill -9)\n\/home\/b6789$kill    -9   372912\n\nThis signal cannot be ignored . You can kill any of the process initiated by you, i:e from your  user id this way .A root user has the privilege of killing any user\u2019s  processes .\n\nExample 2)\nYou  can also  get  the specific PID  for your command without having to search it using grep and awk along with ps. Then kill the PID which you have retrieved.\n\nIf you had to kill the CMD start-atm.java above,\n\/home\/b6789$j_pid=`ps  \u2013fu  $LOGNAME | grep  start-atm.java | grep \u2013v grep | awk \u2019{print  $2}\u2019`\n\/home\/b6789$echo  $ j_pid\n409806\n\/home\/b6789$kill   -9   $ j_pid\n\nYou can also use xargs  to kill process of a particular type all  at once .\n\nExample 3)\nThere is a method to kill all the processes initiated by you,            \n\n\/home\/b6789$kill  -9   -1\n\nThis will kill all the processes of your user id and also  closes  your login session. It is a very dangerous command ,so think thrice  and  check whether any required process is still running using ps before you press enter.\n\n\n\n\nYou can send many kinds  of  signals to a process(not all)   by using  kill  -<signal>  PID. The various signal numbers and their names are listed below  (for AIX) in detail .A short list can also be viewed<br \/>\nby using  kill  -l (lowercase  alphabet  L).<\/p>\n<p>Name      num       Description<br \/>\nSIGHUP      1           hangup, generated when terminal disconnects<br \/>\nSIGINT       2           interrupt, generated from terminal special char<br \/>\nSIGQUIT    3           (*) quit, generated from terminal special char<br \/>\nSIGILL        4           (*) illegal instruction (not reset when caught)<br \/>\nSIGTRAP    5           (*) trace trap (not reset when caught)<br \/>\nSIGABRT    6          (*) abort process<br \/>\nSIGEMT     7           EMT instruction<br \/>\nSIGFPE       8           (*) floating point exception<br \/>\nSIGKILL     9           kill (cannot be caught or ignored)<br \/>\nSIGBUS     10         (*) bus error (specification exception)<br \/>\nSIGSEGV   11         (*) segmentation violation<br \/>\nSIGSYS      12         (*) bad argument to system call<br \/>\nSIGPIPE    13         write on a pipe with no one to read it<br \/>\nSIGALRM  14         alarm clock timeout<br \/>\nSIGTER M  15        software termination signal<br \/>\nSIGURG     16         (+) urgent condition on I\/O channel<br \/>\nSIGSTOP   17         (@) stop (cannot be caught or ignored)<br \/>\nSIGTSTP   18         (@) interactive stop<br \/>\nSIGCONT                  19         (!) continue (cannot be caught or ignored)<br \/>\n SIGCHLD   20        (+) sent to parent on child stop or exit<br \/>\n SIGTTIN   21         (@) background read attempted from control terminal<br \/>\n SIGTTOU   22        (@) background write attempted to control terminal<br \/>\n SIGIO       23         (+) I\/O possible, or completed<br \/>\n SIGXCPU  24         cpu time limit  exceeded<br \/>\n SIGXFSZ   25         file size limit exceeded<br \/>\n SIGMSG    27         input data is in the ring buffer<br \/>\n SIGWINCH  28      (+) window size changed<br \/>\n SIGPWR    29        (+) power-fail restart<br \/>\n SIGUSR1   30        user defined signal 1<br \/>\n SIGUSR2   31        user defined signal 2<br \/>\n SIGPROF   32        profiling time alarm<br \/>\n SIGDANGER 33     system crash imminent; free up some page space<br \/>\n SIGVTALRM 34     virtual time alarm<br \/>\n SIGMIGRATE 35   migrate process<br \/>\n SIGPRE    36         programming exception<br \/>\n SIGVIRT   37         AIX virtual time alarm<br \/>\n SIGALRM1  38      m:n condition variables &#8211; RESERVED &#8211; DON&#8217;T USE<br \/>\n SIGTALRM  38      per-thread alarm clock<br \/>\n SIGWAITING 39   m:n scheduling &#8211; RESERVED &#8211; DON&#8217;T USE<br \/>\n SIGRECONFIG 58  Reserved for Dynamic Reconfiguration Operations<br \/>\n SIGCPUFAIL 59    Predictive De-configuration of Processors \u2013 (RESERVED &#8211; DON&#8217;T USE   )                   <\/p>\n<p> SIGKAP    60              keep alive poll from native keyboard<br \/>\n SIGGRANT  SIGKAP  monitor mode granted<br \/>\n SIGRETRACT 61      monitor mode should be relinquished<br \/>\n SIGSOUND  62        sound control has completed<br \/>\n SIGSAK    63         secure attention key                                           <\/p>\n<p>Example 4)<br \/>\nYou can  stop a running process in the midway and then continue it from that point using kill command.<br \/>\nAssume  you are running a ftp command and want to stop  the file transfer.<br \/>\n\/home\/b6789$ ftp   10.42.67.125<br \/>\n\u2026\u2026<br \/>\n\u2026\u2026.<br \/>\nput abigfile.txt<br \/>\n#####################################<\/p>\n<p>Now in between if you want to suspend it. take an other session for the same user and run<br \/>\nkill  -17 <ftp_PID>,<\/p>\n<p>where <ftp_PID>  is the PID of the ftp command. This sends the signal SIGSTOP to the command. you can observe that the file transfer is stopped.<\/p>\n<p>To restart the command,simply run<br \/>\nKill -19  <ftp_PID> , which sends the signal SIGCONT which is to continue  a  process. The file transfer starts from the point where it stopped.<\/p>\n<p>Similarly other commands ,jobs  or utilities can be stopped and continued using kill -17 and kill -19 resp.<\/p>\n<p>Example 5)<br \/>\nTo Kill all the child processes of a particular process use<br \/>\nkill  -9  &#8211;<parent pid>\nto kill all child processes of PID 204567<br \/>\nkill   -9  -204567<\/p>\n<p>head<\/p>\n<p>head<br \/>\nhead command is used to view or save a specified portion of the beginning of a file.<br \/>\nIt  does  the same work as tail does for the end of the file.<\/p>\n<p>Example 1)<br \/>\nHead by default displays first 10 lines of a file when no option is specified.<br \/>\n\/home\/ftpusr$ head    blackwater.ns<br \/>\nBlackwater USA was formed in 1997, by Erik Prince in North Carolina, to provide training support to military and law enforcement organizations. In explaining the Blackwater&#8217;s purpose, Prince stated that \u2018\u2018We are trying to do for the national security apparatus what FedEx did for the Postal Service.\u2019\u2019After serving SEAL and SWAT teams, Blackwater USA received their first government contract after the bombing of the USS Cole off of the coast of Yemen in October of 2000. After winning the bid on the contract, Blackwater was able to train over 100,000 sailors safely.Prince purchased about 7,000 acres (28 km2) (from Dow Jones Executive, Sean Trotter) of the Great Dismal Swamp, a vast swamp on the North  Carolina\/Virginia border, now mostly a National Wildlife Refuge. &#8220;We needed 3,000 acres to make it safe,&#8221; Prince told reporter Robert Young Pelton.There, he created his state-of-the-art private training facility and his contracting company, Blackwater, which he named for the peat-colored water of the swamp. The The Blackwater Lodge and Training Center officially opened on May 15, 1998 with a 6,000 acre facility and cost $6.5 million.<\/p>\n<p>If   you  wish  to view only first two  lines of the file, use<br \/>\n\/home\/ftpusr$  head -2  blackwater.ns<br \/>\nBlackwater USA was formed in 1997, by Erik Prince in North Carolina, to provide training support to military and law enforcement organizations. In explaining the Blackwater&#8217;s purpose, Prince stated that \u2018\u2018We are trying to do for the<\/p>\n<p>Example 2)<br \/>\nwhen you have a very large file(say of 100000 lines)  and it is difficult to open such a file in vi, but you are concerned only with first  few  lines of the file.<br \/>\nIn that case  redirect  the first  few  lines of that huge file  into  another file and open that file in vi.<\/p>\n<p>\/home\/ftpusr$ head  -1000  migratory_note   > migratory_note_1000<br \/>\n\/home\/ftpusr$vi  migratory_note_1000<br \/>\n..<br \/>\n..<\/p>\n<p>Example 3)<br \/>\nIn  scripts, there are times  where  you  initialize the   output of grep to a variable but  grep searches and returns multiple values, you can use only the first returned value by head -1,<br \/>\nConfused..?the example below shows how.<\/p>\n<p>\/home\/ftpusr$<br \/>\n\/home\/ftpusr$b=`grep  7   prime_numbers`<br \/>\n\/home\/ftpusr$echo $b<br \/>\n7<br \/>\n17<br \/>\n37<\/p>\n<p>Suppose you want the first occurring prime number containing 7,<br \/>\nUse head as follows.<br \/>\n\/home\/ftpusr$b=` grep  7   prime_numbers | head  -1`<br \/>\n\/home\/ftpusr$echo  $b<br \/>\n7<\/p>\n<p>Example 4)<br \/>\nTo print the nth line of a file, use  head and tail in combination as follows.<\/p>\n<p>\/home\/ftpusr$ head -100 operating-out.sh |  tail  -1<br \/>\nThis prints 100th  line of the file.<\/p>\n<p>gzip and tar<\/p>\n<p> gzip and tar<br \/>\ngzip  is used to compress files and tar  is used to archive a file system. Though these two are different commands ,using them together can  accomplish a variety of tasks which seem to be<br \/>\nmuch simpler  than  when  running them separately. Here we will also discuss about the combined  use of tar and cd commands.<\/p>\n<p>First we will discuss with examples the individual command usages of gzip and tar and later use them in combination.<br \/>\ngzip<\/p>\n<p>Example 1)<br \/>\ngzip  is a compression utility that uses Huffman  coding to compress files and save them in .gz format . The  .gz  file occupies  lesser space than   the original file. We will not discuss about the .gz file format , but only show how the command  can be used along with its options.<\/p>\n<p>To compress a file  stake-holder.csv ,<br \/>\n\/home\/gr-adm $ ls \u2013lrt  stake-holder.csv*<br \/>\n-rw-r&#8211;r&#8211;    1 gr-adm  Administ    56344 Dec 16 14:37 greenlife.txt<\/p>\n<p>\/home\/gr-adm$ gzip  file  stake-holder.csv<br \/>\n\/home\/gr-adm$ l s   -lrt  stake-holder.csv*<br \/>\n-rw-r&#8211;r&#8211;    1 kaushik  Administ    20758 Dec 16 14:37 greenlife.txt.gz<\/p>\n<p>Example 2)<br \/>\nIf you want to retain the original file even after compression or want the .gz file to have a different name, use gzip \u2013c.<\/p>\n<p>To  compress the file stake-holder.csv and save the  .gz file in some other directory,<\/p>\n<p>\/home\/gr-adm$ gzip  -c  stake-holder.csv   >\/backup\/stakes\/ stake-holder.csv.gz.<\/p>\n<p> You can also append the compressed file into an existing  .gz file.<br \/>\ngzip  -c  stake-holder.csv    >>\/backup\/stakes\/Old-stake-holder.csv.gz<\/p>\n<p>Here , Old-stake-holder.csv.gz can be a pre existing .gz file or a new file  with that name will be created.<\/p>\n<p>Example 3)<br \/>\nTo decompress the .gz file use gunzip  <filename.gz>,<br \/>\n\/home\/gr-adm$ gunzip    \/backup\/stakes\/stake-holder.csv.gz<br \/>\nThis command will decompress the file stake-holder.csv.gz  and  places the original file<br \/>\nstake-holder.csv in \/backup\/stakes\/ itself.<\/p>\n<p>Example 4)<br \/>\nTo  view the contents of the file without  completely decompressing the file  , use gzip \u2013dc.<br \/>\nUse pg command to view it pagewise..<br \/>\n\/home\/gr-adm$ gzip  -dc  stake-holder.csv.gz  |  pg<br \/>\nA premji, wipro,67<br \/>\nN R murthy,Infosys,65<br \/>\nN Chandra,TCS,46<br \/>\n&#8230;<br \/>\n..<br \/>\nYou can redirect the output into another file,<br \/>\nFor eg to redirect first 5 lines of  the  file stake-holder.csv.gz   ,<\/p>\n<p>gzip  \u2013dc  stake-holder.csv.gz   | head  -5  >stake-holder-five.csv.<\/p>\n<p>tar.<\/p>\n<p>tar is a short form for tape archive. It  can  create  a single file with  the contents of a directory structure   in one path  or extract a  file into directory structure in another path.<\/p>\n<p>Example1)<br \/>\nTo  create  a tar file of a directory structure and to view the progress of tar  use,<\/p>\n<p>\/home\/gr-adm$ tar  -cvf   \/archives\/archive2\/data-history.tar    data\/notes<br \/>\na data\/notes\/Nov-10\/exceptions.txt    200 bytes<br \/>\na data\/notes\/Nov-12\/promotions.csv     123 bytes<br \/>\na data\/notes\/N0v-13\/oracle-log\/ora-errors.log    456  bytes<br \/>\na data\/notes\/tea-time.in     2076 bytes<br \/>\na data\/notes\/network\/virtual-ips.bmp    1290bytes<br \/>\na data\/notes\/levy.list   87bytes<br \/>\n\/home\/gr-adm $<\/p>\n<p>This creates an archive file  data-history.tar    in the path \/archives\/archive2   which contains the directory  \/home\/notes and all its  files and directory structure.<\/p>\n<p>Example2)<br \/>\nTo extract the contents of the archive file into a different location , first change your working directory to the location where you  wish to extract the file, then extract and view the progress by running tar  with \u2013xvf  switch.<\/p>\n<p>\/home\/gr-adm$ cd   \/base-app\/archive<br \/>\n\/home\/gr-adm$   tar   -xvf   \/archives\/archive2\/data-history.tar<br \/>\nx  data\/notes\/Nov-10\/exceptions.txt    200  bytes<br \/>\nx  data\/notes\/Nov-12\/promotions.csv     123 bytes<br \/>\nx  data\/notes\/N0v-13\/oracle-log\/ora-errors.log    456  bytes<br \/>\nx  data\/notes\/tea-time.in<br \/>\nx  data\/notes\/network\/virtual-ips.bmp<br \/>\nx  data\/notes\/levy.list<br \/>\n\/home\/gr-adm $<\/p>\n<p>Example3)<br \/>\nInstead  of   giving  entire directory name  as  a parameter to create a tar file, a   list of files which  care to be archived can be can be passed to tar with \u2013L option.<br \/>\nA file containing the list of files to take tar is as shown.<br \/>\n\/home\/gr-adm$ cat  to-tar-list<br \/>\ndata\/notes\/Nov-10\/exceptions.txt<br \/>\ndata\/notes\/N0v-13\/oracle-log\/ora-errors.log<br \/>\ndata\/notes\/levy.list<\/p>\n<p>Now to create an archive of only these specific files ,use tar in the following manner.<\/p>\n<p>\/home\/gr-adm$ tar  -cvf   \/archives\/archive2\/data-specific.tar     -L   to-tar-list<br \/>\na  data\/notes\/Nov-10\/exceptions.txt      200 bytes<br \/>\na  data\/notes\/N0v-13\/oracle-log\/ora-errors.log           456 bytes<br \/>\na  data\/notes\/levy.list    87 bytes<\/p>\n<p>Example4)<br \/>\nSometimes  you  may need to exclude  files from  the tar archive. To do this place the files  and directories to be excluded in a list file and then use tar \u2013X  <exclude-list>.<\/p>\n<p>\/home\/gr-adm$ cat  \/home\/fiuser\/excl-list<br \/>\ndata\/notes\/Nov-10\/exceptions.txt<br \/>\ndata\/notes\/Nov-12\/promotions.csv<br \/>\ndata\/notes\/N0v-13\/oracle-log\/ora-errors.log   <\/p>\n<p>\/home\/gr-adm$ tar  -X  \/home\/fiuser\/excl-list   -cvf  \/archives\/data-specific2 .tar    data\/notes<br \/>\na data\/notes\/tea-time.in     2076 bytes<br \/>\na data\/notes\/network\/virtual-ips.bmp    1290bytes<br \/>\na data\/notes\/levy.list   87bytes<\/p>\n<p>Example5)<br \/>\nThe  contents of the tar file cannot be viewed directly by cat or more , but  to view the details of the  files and directories contained in the tar file ,use tar \u2013tvf<\/p>\n<p>\/home\/gr-adm$ tar  -tvf   \/archives\/data-specific2 .tar<br \/>\n-rw-r&#8211;r&#8211;       gr-adm      2076        2011-12-16   15:52:55     data\/notes\/tea-time.in<br \/>\n-rw-r&#8211;r&#8211;       gr-adm      1290        2011-12-30   22:44:59    data\/notes\/network\/virtual-ips.bmp<br \/>\n-rw-r&#8211;r&#8211;       gr-adm       87             2011-12-30   22:45:48    data\/notes\/levy.list    <\/p>\n<p>Now that we have gone through tar and gzip individually in detail, let us discuss  with examples  the  use of combined forces of  tar and cd command.<\/p>\n<p>\u00b7      to take the tar of  data\/notes  directory and  untar   the contents  in  \/archives\/archive2<\/p>\n<p>tar  cvf  \u2013  data\/notes | (cd  \/archives\/archive2;tar xvf  &#8211; )<\/p>\n<p>\u2018 \u2013\u2018   refers to the  console .so it means you are passing the output of  tar  -cvf  to   tar \u2013xvf  and changing your path to  \/archives\/archive2.<\/p>\n<p>\u00b7   to take the tar of  local directory data\/notes  and untar the contents in  a directory \/archives\/archive2   of  remote machine  10.198.150.45<\/p>\n<p>tar  cvf  &#8211;  data\/notes | rsh  10.198.150.45  -l  remuser  &#8220;cd \/archives\/archive2;tar xvf -;&#8221;<\/p>\n<p>\u00b7     to take the tar of files in list file tar_list_1 and untar in \/archives\/archive2<\/p>\n<p>             tar  cvf  &#8211; `cat tar_list_1` | (cd   \/archives\/archive2;tar xvf  &#8211; )<\/p>\n<p>\u00b7       to take the tar of files in a local  list file tar_list_1 and untar in \/archives\/archive2 of  a            remote machine 10.198.150.45<\/p>\n<p>tar cvf &#8211; `cat tar_list_1` | rsh  10.198.150.45 &#8211; l remuser  &#8220;cd \/archives\/archive2;tar xvf  -&#8221;<\/p>\n<p>\u00b7       to take the tar of data\/notes directory excluding those in excl_list_tar  and untar its contents     in \/archives\/archive2<\/p>\n<p>                 tar   \u2013X   excl_list_tar   cvf &#8211; data\/notes | (cd   \/archives\/archive2;tar xvf -)<\/p>\n<p>Finally we will discuss with examples   the combined use of gzip and tar.<\/p>\n<p>\u00b7      to gunzip a zipped tar file  data_archive.tar.gz and untar It in \/archives\/archive2 .<\/p>\n<p>gzip  -dc  data_archive.tar.gz  &#8211; | (cd \/archives\/archive2;tar xvf  -)<\/p>\n<p>\u00b7      to gunzip a local  zipped tar  file  data_archive.tar.gz  and untar it in \/archives\/archive2   of      a  remote machine 10.198.150.45<br \/>\n gzip -dc data_archive.tar.gz  &#8211; | rsh 10.198.150.45 -l  fnsonlad  &#8220;cd \/archives\/archive2;tar  xvf  \u2013\u201c<\/p>\n<p>\u00b7      To  view the contents of a zipped tar file without  unzipping it, page wise<\/p>\n<p>       gzip -dc data_archive.tar.gz  &#8211; |  tar  tvf  &#8211;  |pg<\/p>\n<p>find<\/p>\n<p>find<br \/>\nfind  command helps you to find files in a directory  structure much faster than ls command for<br \/>\nvarious options. It can widely be used for getting the list of files in a directory  and its sub directories<br \/>\nwith a given condition on file time stamp, size, name and so on.<\/p>\n<p>Example 1) Suppose that you want to know the entire directory  structure in a<br \/>\nParticular path, then use the find command as follows.<br \/>\n \/home\/Varsha $  find   .  \u2013type  d<br \/>\n.\/ebooks\/perl<br \/>\n.\/ebooks\/perl\/1.Strings<br \/>\n.\/ebooks\/perl\/10.Subroutines<br \/>\n.\/ebooks\/perl\/11.Ref and REcs<br \/>\n.\/ebooks\/perl\/12.Packages, Libraries, and Modules<br \/>\n.\/ebooks\/perl\/13.Classes, Objects, and Ties<br \/>\n.\/ebooks\/perl\/14.Database Access<br \/>\n.\/songs\/hindi\/songs collection\/15 jab we met<br \/>\n.\/songs\/hindi\/songs collection\/1942 A Love Story<br \/>\n.\/songs\/hindi\/songs collection\/20 hey baby<br \/>\n.\/songs\/hindi\/songs collection\/22 jhoom barabar jhoom<br \/>\n.\/.\/songs\/hindi\/songs collection\/26 let the music play 3++<br \/>\n.\/songs\/hindi\/songs collection\/Aa Dekhe Zara<br \/>\n.\/songs\/hindi\/songs collection\/Aap Kaa Suroor<br \/>\n.\/songs\/hindi\/songs collection\/Aashiq Banaya Aap Ne<br \/>\n.\/songs\/hindi\/songs collection\/Rockstar<br \/>\n.\/songs\/hindi\/songs collection\/3 idiots<br \/>\n.<br \/>\n.<br \/>\n.<br \/>\n.<br \/>\n ^C<br \/>\nIt seems varsha listens to these  songs while her boss is not around .<\/p>\n<p>This command searched all the directories  starting from  \/home\/Varsha  and displayed it.<br \/>\nSimilarly for displaying all the files you can use   -type f option. Here the   \u2018.\u2019  In the command refers to the current directory.<br \/>\nYou can use any directory name as the base directory for find to search<\/p>\n<p>To  display everything(i:e  all<br \/>\nDirectories and  files) use.<br \/>\nfind  .  &#8211; print<\/p>\n<p>Example 2)<br \/>\nYou want the output to be similar to that of ls command, use find as follows.<br \/>\n \/home\/Varsha $  find  &#8211; type  f  -ls<br \/>\n244269   33 -rw-r&#8211;r&#8211;   1 Varsha  Trainee       60 Nov  9 23:58 .\/ebooks\/perl\/1.Strings\/chapter1<br \/>\n235915   86 -rw-r&#8211;r&#8211;   1 Varsha  Trainee      215 Nov  9 11:26 .\/ebooks\/perl\/1.Strings\/chapter2<br \/>\n104841   25 -rw-r&#8211;r&#8211;   1 Varsha  Trainee      554 Nov  9 11:26 .\/ebooks\/perl\/1.Strings\/chapter3<br \/>\n104838   32 -rw-r&#8211;r&#8211;   1 Varsha  Trainee      510 Nov  9 11:26 .\/ebooks\/perl\/10.Subroutines\/chapter1<br \/>\n104840   33 -rw-r&#8211;r&#8211;   1 Varsha  Trainee       55 Nov  9 11:26 .\/ebooks\/perl\/10.Subroutines\/chapter2<br \/>\n..<br \/>\n^C<\/p>\n<p>The output you get are the values included in the following order<br \/>\nI-node number<br \/>\n Size in kilobytes (1024 bytes)<br \/>\n Protection mode<br \/>\n Number of hard links<br \/>\n User<br \/>\n Group<br \/>\n Size in bytes<br \/>\n Modification time               <\/p>\n<p>Example 3)<br \/>\n Find also helps in retrieving the files which are a modified  n days before or modified after n days. Where  n is any integer.<br \/>\nSuppose you want the list of all the files which are modified   5 days  ago so that it can be removed after archiving It.<br \/>\n\/home\/varsha $ date<br \/>\nFri Dec 23 21:16:06 IST 2011<br \/>\n\/home\/varsha $  find   . \u2013type  f  -mtime +5     >file_list_5<\/p>\n<p>Then use this file list(file_list_5)  to take a tar of the file, or to remove those files and save this file as a  copy of \u2018which files have been archived\u2019.<br \/>\nSimilarly you can use -5  instead of  +5 for files modified after 5 days.<\/p>\n<p>Example 4)<br \/>\nto find all the find all the files which are greater or less than a particular size, use \u2013size option.<\/p>\n<p>Suppose you want the list of files which are of size greater than 100kB,use find as follows.<br \/>\n\/home\/varsha $ find  .  \u2013size  +100c<\/p>\n<p>Example 5)<br \/>\nTo find all files  which are created after the modification time of a particular file,use find with -newer option.<br \/>\nIf you want to list all the files that were created after 2013-05-31 06:25  <\/p>\n<p>\/home\/varsha\/$ touch -t 201305310625  test_file<\/p>\n<p>home\/varsha\/$  ls  -lrt   test_file<br \/>\n244269   33 -rw-r&#8211;r&#8211;   1 Varsha  Trainee       0 May 31  06:25<\/p>\n<p>home\/varsha\/$ find . -newer  test_file<br \/>\n.\/BATCH<br \/>\n.\/BATCH\/arguments.bat<br \/>\n.\/BATCH\/arith.bat<br \/>\n.\/BATCH\/for_loop.bat<br \/>\n.\/BATCH\/if_condn.bat<br \/>\n.\/BATCH\/if_condn.bat.bak<br \/>\n.\/misc<br \/>\n.\/misc\/vim_list.txt<br \/>\n.\/PERL<br \/>\n.\/PERL\/a1.txt<br \/>\n.\/PERL\/a1.txt.orig<br \/>\n.\/PERL\/a2.txt<br \/>\n.\/PERL\/a2.txt.orig<br \/>\n.\/PERL\/all_dir.txt<\/p>\n<p>You can verify it by using -ls option.<\/p>\n<p>echo<\/p>\n<p>echo<\/p>\n<p>echo is used to display characters into standard output. It can also be used to write to a file<br \/>\nor  just to print a newline character.<\/p>\n<p>Example1)<br \/>\nIt can be used to print a string and a variable together.<\/p>\n<p>\/home\/b4578$ echo  \u201c my Home is $HOME\u201d<br \/>\nMy Home is \/home\/b4578<br \/>\n\/home\/b4578$<\/p>\n<p>To print the $symbol use a backslash \u201c\\\u201d character.<br \/>\nie:-<br \/>\n\/home\/b4578$ echo  \u201cmy \\$HOME variable is set to $HOME\u201d<br \/>\nmy \\$HOME variable is set to \/home\/b4578<\/p>\n<p>Example 2)<br \/>\nTo display double quote character \u201c use a backslash.<br \/>\nSuppose you want to display   a  html form tag. use echo as shown in a script.<br \/>\n#!\/usr\/bin\/sh<br \/>\n#&#8230;&#8230;&#8230;.lines of code<br \/>\necho \u201c<html>\u201d<br \/>\necho \u201c<body>\u201d<br \/>\necho \u201c<\/p>\n<form action = \\\u201dstratnew.js\\\u201d method = \\\u201dpost\\\u201d>\necho \u201c<input type = \\\u201dtext\\\u201d name = \\\u201dhname\\\u201d ><br \/>\n&#8230;&#8230;&#8230;. # lines of  html form<br \/>\necho \u201c<\/form>\n<p>\u201d<br \/>\necho \u201c<\/body>\u201d<br \/>\necho \u201c<\/html>\u201d<\/p>\n<p>when you run the script the output will be<br \/>\necho \u201c<html>\u201d<br \/>\necho \u201c<body>\u201d<br \/>\necho \u201c<\/p>\n<form action = \u201dstratnew.js\u201d method = \u201dpost\u201d>\necho \u201c<input type = \u201dtext\u201d name = \u201dhname\u201d ><br \/>\n&#8230;&#8230;&#8230;. # lines of  html form<br \/>\necho \u201c<\/form>\n<p>\u201d<br \/>\necho \u201c<\/body>\u201d<br \/>\necho \u201c<\/html>\u201d<\/p>\n<p>Example 3)<br \/>\nto just display a newline in the output of a script, simply place an  echo.<\/p>\n<p>Example 4)<br \/>\n To write the output of echo command to a file use \u201c>\u201d to redirect the output of echo.<br \/>\n\/home\/b4578$echo  \u201c my logpath is $LOGPATH\u201d  >>file_log.txt<br \/>\n\/home\/b4578$tail   -1  file_log.txt<br \/>\nmy logpath is  \/home\/b4578\/user\/logs<br \/>\nExample 5)<br \/>\nTo give an audible alert(a bell) use \\a inside echo<br \/>\nFor example to make an alarm script which beeps continuously when there is any error, the echo command can be used as shown.<br \/>\n\/home\/b4578$vi   check _transactions.sh<br \/>\n&#8230;.<br \/>\nalarmfunc( )<br \/>\n{<br \/>\nWhile  [ 1 ]           # always condition<br \/>\ndo<br \/>\necho  \u201c\\a There is some problem\u201d        #beep continuously with a gap of one second.<br \/>\nsleep 1<br \/>\ndone<br \/>\n}<br \/>\n&#8230;.<br \/>\n&#8230;<br \/>\nIf  [  $tran_time_before   -gt   20 ]<br \/>\nalarmfunc<br \/>\nfi<br \/>\n&#8230;.<br \/>\n&#8230;<br \/>\n\/home\/b4578$<\/p>\n<p>Escape sequences  which are recognised by echo are listed below.<\/p>\n<p>\\a    Displays an alert character.<\/p>\n<p>\\b   Displays a backspace character.<\/p>\n<p>\\c    Suppresses the new-line character that otherwise follows the final argument in the output.<br \/>\n         All characters  following the \\c sequence are ignored.<\/p>\n<p>\\f   Displays a form-feed character.<\/p>\n<p>\\n   Displays a new-line character.<\/p>\n<p>\\r    Displays a carriage return character.<\/p>\n<p>\\t    Displays a tab character.<\/p>\n<p>\\v    Displays a vertical tab character.<\/p>\n<p>\\\\    Displays a backslash character.<\/p>\n<p>date<\/p>\n<p>date  <\/p>\n<p>date can be used by a lot of applications in various forms. you may require to access a month,day, hour or second of  a particular date.<\/p>\n<p>You may use the following options to achieve these functionalities.<\/p>\n<p>%%   a literal %<br \/>\n %a   locale&#8217;s abbreviated weekday name (Sun..Sat)<br \/>\n %A   locale&#8217;s full weekday name, variable length (Sunday..Saturday)<br \/>\n %b   locale&#8217;s abbreviated month name (Jan..Dec)<br \/>\n %B   locale&#8217;s full month name, variable length (January..December)<br \/>\n %c   locale&#8217;s date and time (Sat Nov 04 12:02:33 EST 1989)<br \/>\n %d   day of month (01..31)<br \/>\n %D   date (mm\/dd\/yy)<br \/>\n %e   day of month, blank padded ( 1..31)<br \/>\n %h   same as %b<br \/>\n %H   hour (00..23)<br \/>\n %I   hour (01..12)<br \/>\n %j   day of year (001..366)<br \/>\n %k   hour ( 0..23)<br \/>\n %l   hour ( 1..12)<br \/>\n %m   month (01..12)<br \/>\n %M   minute (00..59)<br \/>\n %n   a newline<br \/>\n %p   locale&#8217;s AM or PM<br \/>\n %r   time, 12-hour (hh:mm:ss [AP]M)<br \/>\n %s   seconds since 00:00:00, Jan 1, 1970 (a GNU extension)<br \/>\n %S   second (00..60)<br \/>\n %t   a horizontal tab<br \/>\n %T   time, 24-hour (hh:mm:ss)<br \/>\n %U   week number of year with Sunday as first day of week (00..53)<br \/>\n %V   week number of year with Monday as first day of week (01..52)<br \/>\n %w   day of week (0..6);  0 represents Sunday<br \/>\n %W   week number of year with Monday as first day of week (00..53)<br \/>\n %x   locale&#8217;s date representation (mm\/dd\/yy)<br \/>\n %X   locale&#8217;s time representation (%H:%M:%S)<br \/>\n %y   last two digits of year (00..99)<br \/>\n %Y   year (1970&#8230;)<br \/>\n %z   RFC-822 style numeric timezone (-0500) (a nonstandard extension)<br \/>\n %Z   time zone (e.g., EDT), or nothing if no time zone is determinable<\/p>\n<p>To get the the current  month,year and day in mmddyyyy  format ,enter<\/p>\n<p>date + \u2018 %m%d%Y\u2019<\/p>\n<p>cp<\/p>\n<p>cp<br \/>\ncp is used to copy files with a name to a different name in the same path or to a different path.It can also be used to recursively copy files in a directory structure to a different directory.<\/p>\n<p>Example1)<br \/>\nTo copy file1 to file2<\/p>\n<p>\/home\/justin$cp   sl_ind.ctl  sql_ind2.ctl  <\/p>\n<p>This  copies the contents of the file sl_ind.ctl   to    sql_ind2.ctl  . If there is already a file named     sql_ind2.ctl in the current directory, then the   file will be over written ,if it does not exist, the new file will be created.<\/p>\n<p>If you do not want files to be overwritten  , use \u2013i option. give y or n as reply.<br \/>\nassume    sql_ind2.ctl    already exists.<\/p>\n<p>\/home\/justin$ cp  -i  sql_ind.ctl    sql_ind2.ctl<br \/>\nThis will ask you to whether to overwrite or not.<\/p>\n<p>You can also use wildcards like ? and *   along  with  parameters  that  define a group of  source filenames.<\/p>\n<p>Example 2)<br \/>\n when you copy files from  source to  a different directory ,you do not have to mention the<br \/>\nfilename  in the destination path if you want to keep the name of the file same. Do it<br \/>\nonly  when  destination filename  is to be different.<\/p>\n<p>Suppose \/home\/raja\/libs is a directory,<\/p>\n<p>\/home\/justin$ cp  Jlibs.all.csv    \/home\/raja\/libs   # this will place  Jlibs.all.csv   in \/home\/raja\/libs.<\/p>\n<p>\/home\/justin$ cp  Jlibs.all.csv    \/home\/raja\/libs\/rlibs.all.csv    #This will<br \/>\nCreate rlibs.all.csv     in \/home\/raja\/libs  directory<\/p>\n<p>Example 3)<br \/>\ncp  has option \u2013p for preserving the file attributes like modification time,without this option, cp by default  puts new time stamp for destination files.<\/p>\n<p>\/home\/justin$ls   -lrt  flower?.jpg<br \/>\n-rw-r&#8211;r&#8211;    1 justin  Admin    59254  Jan  03 12:14 flower3.jpg<br \/>\n-rw-r&#8211;r&#8211;    1 justin  Admin    59256 Dec 29 17:22 flower2.jpg<\/p>\n<p>\/home\/justin$cp  -p   flower3.jpg    flower2.jpg<br \/>\n\/home\/justin$ls   -lrt  flower?.jpg<br \/>\n-rw-r&#8211;r&#8211;    1 justin  Admin    59254 Jan 03 12:14 flower2.jpg<br \/>\n-rw-r&#8211;r&#8211;    1 justin  Admin    59254  Jan  03 12:14 flower3.jpg<\/p>\n<p>Example 4)<br \/>\nyou want to completely copy a file system  with all the files and directories in it  and create<br \/>\nthe same directory structure, use cp with \u2013R option.<br \/>\n\/home$ cp  -R  justin  \/backup_justin<br \/>\n\/home$cd  \/backup_justin<br \/>\n\/backup_justin$find  .  \u2013type f<br \/>\nJustin\/ flower3.jpg<br \/>\nJustin\/flower2.jpg<br \/>\nJustin\/ sql_ind.ctl<br \/>\nJustin\/sql_ind2.ctl<br \/>\nJustin\/wildlife\/tiger\/video2.mpg<br \/>\nJustin\/ wildlife\/tiger\/video3.mpg<br \/>\nJustin\/ client-file\/voucher1.txt<\/p>\n<p>chmod<\/p>\n<p>chmod<\/p>\n<p>Using chmod  you can change the permission of single or multiple directories or files.<br \/>\nIn unix, nothing works without proper permissions. To run any script ,the first thing you need to<br \/>\ndo after writing it is to give execute permissions .<\/p>\n<p>To view file permissions. use ls \u2013lrt<\/p>\n<p>Example 1)<br \/>\n\/home\/d456\/$ ls \u2013lrt<\/p>\n<p>-rw-r&#8211;r&#8211;    1 d456  Readers  1181170    Apr 27    2011 apache_manual.tar.gz<br \/>\n-rw-r&#8211;r&#8211;    1 d456  Readers  1128480    Apr 27    2011 perl cookbook.zip<br \/>\n-rw-r&#8211;r&#8211;    1 d456  Readers    70228       May  3    2011  IMP.txt<\/p>\n<p>All the files have read and write permissions to the user read to the group and others.<br \/>\n-rw-r&#8211;r&#8211;     can be interpreted in octal notation as 110-100-100 or 644<br \/>\nTo change the permissions of the file IMP. txt    with read and write to user and<br \/>\n group, only read to  others (rw-rw&#8211;r&#8211;)  ,you can use:<\/p>\n<p>D2-\/home\/d456\/$ chmod  664  IMP.txt<br \/>\nD2-\/home\/d456\/$ ls  \u2013lrt<br \/>\nrw-r&#8211;r&#8211;     1  d456  Readers  1181170    Apr 27    2011  apache_manual.tar.gz<br \/>\n-rw-r&#8211;r&#8211;    1  d456  Readers  1128480    Apr 27    2011 perl cookbook.zip<br \/>\n-rw-rw-r&#8211;  1  d456  Readers    70228       May  3    2011  IMP.txt<br \/>\n-rw-r&#8211;r&#8211;     1 d456  Readers  5748626    May 12   2011 sg245511.pdf<\/p>\n<p>Example 2)<br \/>\n you want to allow all users to  run the  script named script_name.sh<br \/>\n \/home\/d476\/$ chmod   a+x  script_name.sh<br \/>\n\/home\/d476\/$  ls  \u2013lrt  script_name.sh<br \/>\n-rwx -rx&#8211;rx&#8211;     1 d476   Readers  5748626    Jun  10   2011  script_name.sh<\/p>\n<p>Here a in \u2018a+x\u2019  represents all.similarly use \u2018u\u2019  is for user, \u2018g \u2018 for group , \u2018o\u2019\u2019 for others \u2018+\u2019 to give permissions  and \u2018-\u2018  to deny.<\/p>\n<p>Example 3)<br \/>\nYou may have to give  permissions  to all the files in a directory tree use \u2013R option.<br \/>\nTo give all files and directories  read ,write and  execute permissions in \/home directory ,<\/p>\n<p>D2- \/home $ chmod   -R  777  *<br \/>\nchmod:  \/home\/ d476\/relativity.txt       operation not permitted<br \/>\nchmod :  \/home\/ d476\/ source3.sh         operation not permitted      <\/p>\n<p>You will definitely get these errors if you are not an admin user  or logged in as a different user.<\/p>\n<p>cd<\/p>\n<p>cd<\/p>\n<p>cd command helps you to move around directories. various options of cd helps you<br \/>\nin navigating between your current directory to previous working  directory, or one directory<br \/>\nbehind and so on..<\/p>\n<p>cd   in unix provides much more options than the cd in DOS. you will see in these examples.<\/p>\n<p>1)      You  are working in a directory other than your home and want  to go to your home directory($HOME), just enter cd.<\/p>\n<p>\/home\/dimuser\/functions\/standard\/cpp$ echo $HOME<br \/>\n\/home\/b768<\/p>\n<p>\/home\/dimuser\/functions\/standard\/cpp$ cd<br \/>\n\/home\/b768 $<br \/>\n\u2018cd \u2018 is same as \u2018cd $HOME\u2019<\/p>\n<p>2)      You need to go to your last working directory.<\/p>\n<p>\/home\/b768$ cd \/var\/utilities<\/p>\n<p>\/var\/utilities$ cd  &#8211;<br \/>\n\/home\/b768           #here it echoes the directory into which you are moving<br \/>\n\/home\/b768 $cd \u2013<br \/>\n\/var\/utilities<br \/>\n\/var\/utilities$<\/p>\n<p>3)      To move  one directory behind use \u2018 ..\u2019 ,ie two dots<br \/>\n\/home\/b768$ cd  ..<br \/>\n\/home$<\/p>\n<p>Note that \u2018.\u2019 Refers to the current directory and \u2018..\u2019 refers to a directory behind<\/p>\n<p>4) To interchange similar directory structures as your current working directory.<br \/>\n     \/home\/b768\/test\/ALG\/bin $cd  test  prod<br \/>\n    \/home\/b768\/prod\/ALG\/bin<br \/>\n    \/home\/b768\/prod\/ALG\/bin$<\/p>\n<p>Ensure here that the destination directory structure exists.<br \/>\nYou can also simply change any particular string or a number in a directory name to a new one<br \/>\nand  move to the new directory path if it exists.<br \/>\nie :-<br \/>\n    \/home\/b768\/prod\/ALG\/bin$cd  68  54<br \/>\n      \/home\/b768\/prod\/ALG\/bin<br \/>\n     \/home\/b754\/prod\/ALG\/bin$<\/p>\n<p>cat<\/p>\n<p>cat<br \/>\ncat  can be used to open  one or a group of  files ,  append  files into one file. one  of the special functionality is  to read an entire file  line by line along with the read command. The examples will show us how.<br \/>\nExample 1)<br \/>\n\/home\/b3456\/$ cat  branches1.txt                      (Note: here \/home\/b3456\/$ is the prompt<br \/>\n35467       vdn          \/home\/vd2<br \/>\n46788       ghi        \/home\/gh1\/gh<br \/>\n89078       bjk       \/home\/vd2<\/p>\n<p>\/home\/b3456\/$ cat  branches2.txt<br \/>\n56890      lod          \/home\/lod\/inter<br \/>\n33456       bhj       \/home\/bhind<br \/>\n45790       krk       \/myhome\/krk<\/p>\n<p>Combining these two files into a single file can be done by<br \/>\n\/home\/b3456\/$ cat  branches1.txt  cat  branches2.txt<\/p>\n<p>35467       vdn          \/home\/vd2<br \/>\n46788       ghi        \/home\/gh1\/gh<br \/>\n89078       bjk       \/home\/vd2<br \/>\n56890       lod          \/home\/lod\/inter<br \/>\n33456       bhj       \/home\/bhind<br \/>\n45790       krk       \/myhome\/krk<\/p>\n<p>          Or by<br \/>\n\/home\/b3456\/$  cat  branches[1-2].txt<\/p>\n<p>Suppose you have many such files named branches1.txt branches2.txt branches3.txt\u2026 branches<x>.txt  where  <x>  is any  single numeric or alphabetic character, you can use.<br \/>\ncat  branches?.txt to open all  the files.<\/p>\n<p>Example 2)<br \/>\nYou want to write contents you have copied from a file into another file. one way to do it is to open it in a vi editor and then save it.<br \/>\nOther way to do it is by using cat to open a file and paste the contents.<\/p>\n<p>\/home\/b3456\/$ cat  >filetocopy<br \/>\n#the  sentence of these lines<br \/>\nwere copied from a different file<br \/>\nand  pasted here.<br \/>\n#the contents here were typed manually<br \/>\n^D<br \/>\n\/home\/b3456\/$<\/p>\n<p>\/home\/b3456\/$more   filetocopy<br \/>\n#the  sentence of these lines<br \/>\nwere copied from a different file<br \/>\nand  pasted here.<br \/>\n#the contents here were typed manually<\/p>\n<p>\/home\/b3456\/$<\/p>\n<p>A  ^d  character(ctrl + d) must be typed at the end to mark the end of file.<br \/>\nIf you already have  a file with the same name and you want to append the contents copied  into that file,<br \/>\nthen use  \u201c>>\u201d  instead of  \u2018>\u2019<\/p>\n<p>Example 3)<br \/>\nyou can also use cat to read each line of a file into a variable, using read command.<br \/>\nThis  cannot be achieved with a \u2018for   in \u2019 loop since it considers words in a line as separate values assigned to the index variable.<\/p>\n<p>The  following  commands  will tell you  how to achieve it using cat and read with a  while loop.<br \/>\nConsider that you want to  read the file  branches1.txt(example 1) ,in such a way that entire string in  each line is stored  into a variable and then  that variable  is used to extract each fields(separated by spaces)<\/p>\n<p>\/home\/b3456\/$ cat   branches1.txt  | while read line  # the variable line stores the contents of a line<br \/>\ndo<br \/>\nnum=`echo $line  |  awk  \u2018{print $1}\u2019<br \/>\npath=` echo $line  |  awk  \u2018{print $3}\u2019<br \/>\necho  \u201c$path is  the path for $num\u201d<br \/>\ndone<\/p>\n<p>     \/home\/vd2   is the path for  35467<br \/>\n      \/home\/gh1\/gh   is the path for  46788<br \/>\n     \/home\/vd2 is the path for  89078<\/p>\n<p>The \u2018for in\u2019 loop imposes restrictions on the number of lines of a file which can be  by it. But cat has no limitations. It can read any  file, however large it is until the system resource is exhausted.<\/p>\n<p>Example 4)<br \/>\nline numbers of  a  file can be displayed by using  cat with \u2013n option.<br \/>\n\/home\/b3456\/$ cat  -n   branches1.txt  cat  branches2.txt<br \/>\n    1  35467       vdn          \/home\/vd2<br \/>\n    2  46788       ghi        \/home\/gh1\/gh<br \/>\n    3  89078       bjk       \/home\/vd2<br \/>\n    4  56890       lod          \/home\/lod\/inter<br \/>\n    5  33456       bhj       \/home\/bhind<br \/>\n    6  45790       krk       \/myhome\/krk<\/p>\n<p>cal<\/p>\n<p>cal<br \/>\ncal command is basically used to view the calendar.When you are working in unix it becomes necessary  to have a quick look at the calendar, and you need not minimize your terminal session to view it.jut use cal as follows.<br \/>\nEx1) To view the entire calendar of a year.<br \/>\n\/home\/steve $ cal  2011<br \/>\n          January                     February<br \/>\nSun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat<br \/>\n                         1            1   2   3   4   5<br \/>\n 2   3   4   5   6   7   8    6   7   8   9  10  11  12<br \/>\n 9  10  11  12  13  14  15   13  14  15  16  17  18  19<br \/>\n16  17  18  19  20  21  22   20  21  22  23  24  25  26<br \/>\n23  24  25  26  27  28  29   27  28<br \/>\n30  31<br \/>\n           March                        April<br \/>\nSun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat<br \/>\n         1   2   3   4   5                        1   2<br \/>\n 6   7   8   9  10  11  12    3   4   5   6   7   8   9<br \/>\n13  14  15  16  17  18  19   10  11  12  13  14  15  16<br \/>\n20  21  22  23  24  25  26   17  18  19  20  21  22  23<br \/>\n27  28  29  30  31           24  25  26  27  28  29  30<\/p>\n<p>            May                         June<br \/>\nSun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat<br \/>\n 1   2   3   4   5   6   7                1   2   3   4<br \/>\n 8   9  10  11  12  13  14    5   6   7   8   9  10  11<br \/>\n15  16  17  18  19  20  21   12  13  14  15  16  17  18<br \/>\n22  23  24  25  26  27  28   19  20  21  22  23  24  25<br \/>\n29  30  31                   26  27  28  29  30<\/p>\n<p>           July                        August<br \/>\nSun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat<br \/>\n                     1   2        1   2   3   4   5   6<br \/>\n 3   4   5   6   7   8   9    7   8   9  10  11  12  13<br \/>\n10  11  12  13  14  15  16   14  15  16  17  18  19  20<br \/>\n17  18  19  20  21  22  23   21  22  23  24  25  26  27<br \/>\n24  25  26  27  28  29  30   28  29  30  31<br \/>\n31<br \/>\n         September                     October<br \/>\nSun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat<br \/>\n                 1   2   3                            1<br \/>\n 4   5   6   7   8   9  10    2   3   4   5   6   7   8<br \/>\n11  12  13  14  15  16  17    9  10  11  12  13  14  15<br \/>\n18  19  20  21  22  23  24   16  17  18  19  20  21  22<br \/>\n25  26  27  28  29  30       23  24  25  26  27  28  29<br \/>\n                             30  31<br \/>\n         November                     December<br \/>\nSun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat<br \/>\n         1   2   3   4   5                    1   2   3<br \/>\n 6   7   8   9  10  11  12    4   5   6   7   8   9  10<br \/>\n13  14  15  16  17  18  19   11  12  13  14  15  16  17<br \/>\n20  21  22  23  24  25  26   18  19  20  21  22  23  24<br \/>\n27  28  29  30               25  26  27  28  29  30  31<br \/>\nEx 2) To view the calendar of  any month of a given year, use cal with month as first parameter, year as second.<br \/>\n\/home\/steve $ cal 8 1947<br \/>\n        August 1947<br \/>\nSun Mon Tue Wed Thu Fri Sat<br \/>\n                     1   2<br \/>\n 3   4   5   6   7   8   9<br \/>\n10  11  12  13  14  15  16<br \/>\n17  18  19  20  21  22  23<br \/>\n24  25  26  27  28  29  30<br \/>\n31<\/p>\n<p>bc<\/p>\n<p>bc<br \/>\nbc is an important utility provided by unix to do mathematical calculations. This utility can be used as a one line command. you can also program bc  to perform various arithmetic just like that of a C program. It also has a Math library of its own which has functions like sine, cosine, tan and so on, which can be defined by specifying \u2013l option.<\/p>\n<p>For more details on bc you can refer to these url s  on bc.<br \/>\nhttp:\/\/www.gnu.org\/software\/bc\/manual\/html_mono\/bc.html<br \/>\nhttp:\/\/www.thegeekstuff.com\/2009\/11\/unix-bc-command-line-calculator-in-batch-mode\/<\/p>\n<p>Example1)<br \/>\nto perform a simple arithmetic  2 + 2,you can bc as follows.<br \/>\n\/home\/MS$ bc<br \/>\n2+2&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;>type your expression here<br \/>\n4  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;->Ans                           ,<\/p>\n<p>Example2)<br \/>\nTo run a command containing an expression and evaluate it using bc,<br \/>\n\/home\/MS$ echo \u201c 35.2 \u2013 43.6\u201d | bc<br \/>\n-8.4<\/p>\n<p>Example3)<br \/>\nTo use decimal digits you need to specify scale variable.<br \/>\n\/home\/MS$ bc<br \/>\n6\/9<br \/>\n0<br \/>\nScale=4<br \/>\n6\/9<br \/>\n.6666<\/p>\n<p>basename<\/p>\n<p>basename<br \/>\n basename is used to get the name of the file given its complete path including the file.<br \/>\nIt is also  helpful to access the name of  a script within it.<\/p>\n<p>Ex ample1)<br \/>\nTo get the name of a file from its complete path.<br \/>\n\/home\/gj876$ echo $CGI_PATH<br \/>\n\/utilities\/intranet\/apache\/cgi-docs\/cowboy<br \/>\n\/home\/gj876$ basename $CGI_PATH<br \/>\ncowboy<\/p>\n<p>Example2)<br \/>\nSuppose a script \u201c\/home\/scripts\/linkfiles.sh\u201d is called from   another script with its complete path,then to access the  base filename of  \u201c\/home\/scripts\/linkfiles.sh\u201d, use<br \/>\n#!\/usr\/bin\/ksh<br \/>\nFile_name=`basename $0`<br \/>\necho $File_name<\/p>\n<p>the output will be linkfiles.sh<\/p>\n<p>awk<\/p>\n<p>awk<br \/>\nawk is very good programming language\/command  in manipulating files which have patterns separated by space or other delimiters. It does these  operations  faster than other basic  unix commands like sed and grep.<br \/>\nawk\u2019s power lies in its \u201cone line\u201d editing option which makes it more a command than a programming language.<br \/>\nExamples:<br \/>\nExample1)<br \/>\nsuppose that you have a file which contains 4 columns of an SQL  spool file.<br \/>\n\/home\/b3456\/$ cat  member_list.txt                         (Note: here \/home\/b3456\/$  is the prompt string)<br \/>\nAjit kumar                1000             BLR<br \/>\nsachin Sharma        2500             MUM<br \/>\nAjay gupta                6560             MUM<br \/>\nSrinivasan   R          4509              NDL<br \/>\nAhmed  javed          7845              CHE<\/p>\n<p>To print only the city codes(third field or column ) enter the following  command.<br \/>\n\/home\/b3456\/$ awk  \u2018{print $3}\u2019   member_list.txt<br \/>\nBLR<br \/>\nMUM<br \/>\nMUM<br \/>\nNDL<br \/>\nCHE<\/p>\n<p>Example 2)<br \/>\n you want to get the member whose amount withdrawn ( 2nd  column)  is greater than  or equal to 6000 and less than 7000 ,enter the command<br \/>\n\/home\/b3456\/$ awk  \u2018  {if ( $2  >=  6000 &#038;&#038; $2  < 7000) print $1 }\u2019    member_list.txt\nAjay gupta                \nExample 3)\n To get the total size of a group of files  in  a directory.\n\/home\/b3456\/$  ls  \u2013lrt\n rw-r--r--    1 b3456  Administ    19738       Feb  1  2011  NOV_2010_3.pdf\n-rw-r--r--    1 b3456  Administ    18176      Feb  1  2011  DEC_2010.pdf\n--rw-r--r--    1 b3456  Administ   739840   Jul  8 23:09    2011_ITR1_r2.xls\n-rw-r--r--    1 b3456  Administ    11455     Jul  8 23:13     ITR1_AJTPN1033E.xml\n-rw-r--r--    1 b3456  Administ    94058     Jul  9 14:08     09072011020807_13102006\n-rw-r--r--    1 b3456  Administ      101        Jul  9 14:10     address_TAX.txt\n-rw-r--r--    1 b3456  Administ    43237     Jul  9 14:17     XXXPN1033X_ITR-V.zip\n-rw-r--r--    1 b3456  Administ  1046954  Nov 21 14:29 EDU_LOAN_STMT.pdf\nEnter the following command.\n\n\/home\/b3456\/$  ls  -lrt | awk ' BEGIN  {c = 0}{ c  += $5 } END{print  c}' \n973559\nNote that you don\u2019t have to use \u2018$\u2019 symbol for printing a variable .\n\nExample 4)\nMany a times ,you may want to pass a shell variable to awk  in the command line or inside\nShell-script and do some conditional manipulations based on the variable .\nConsider  a situation where you need to compare  a name variable of the shell with the names in the file member_list.txt.\nThe script\n#!\/usr\/bin\/sh\n\u2026\u2026\u2026\u2026\u2026..#lines of commands\n\u2026\u2026\u2026\u2026\u2026..\np_name=`echo $m_name`         #p_name Is a shell variable.\nawk   -v    myp_name=$ p_name   \u2018{ if  ( $1 == myp_name)  print  $0 }\u2019   member_list.txt.\n\u2026\u2026\u2026\u2026\u2026.\nHere the awk command prints the entire line which contains the name field same as that of value of variable p_name\n\n\n  Example 5)\nA  single space or a  sequence  of  space  characters is the  default delimiter   for fields, if there are any other use  awk   with option \u2013F and mention the delimiter.\nIf the file member_list2.txt contained  the following,\n\/home\/b3456\/$ cat  member_list2.txt\nAjit kumar|1000|BLR\nsachin Sharma|2500|MUM\nAjay gupta|6560|MUM\nSrinivasan R|4509|NDL\nAhmed javed|7845|CHE\nThen  to print only the city codes(third field or column ) as in example 1, awk can be used as follows.\n\n\/home\/b3456\/$ awk  -F  \u201c|\u201d  \u2018{ print $3 }\u2019    member_list2.txt\nBLR\nMUM\nMUM\nNDL\nCHE\n\n\nAWK Examples\n1) An awk script which performs arithmetic.\n\nawk '{\n\nx = 3; y = 3;\n\nprint ($1\/7) + ($2 - y)\/x\n\nz = $2 - 4;\n\nprint z\n\n}'   file_1.txt\n\n2) awk script to print the  filename  and its size and  finally total size occupied by all files.\n\nls -lrt | awk 'BEGIN { c = 0; siz = 0;print FILENAME BYTES}\n\nNF == 9 &#038;&#038; \/^-\/\n\n{\n\nprint $9 \" \" $5;c++;siz += $5\n\n}\n\nEND{\n\nprint \"\\nTOTAL COUNT = \" c \"\\nTOTAL SIZE = \" siz\n\n}'  \n\n\n\n3) consider a file(name_addr.txt)  containing names and addresses with records seperated by a blank line and fields seperated by newline.\n\nkaushik\n\nnayak\n\ndl hsg socty\n\nvashi\n\njose\n\ndmello\n\nms clny\n\nblore\n\nreema\n\nj l\n\nhighway rd\n\nseattle\n\nawk command to extract only first name from this file will be\n\nawk 'BEGIN{FS =\"\\n\";RS=\"\"}\n\n{\n\nprint $1\n\n}' name_addr.txt\n\n\n4)awk command to count the total number of blank lines in a file.\n\nawk ' \/^$\/\n\nBEGIN{ c = 0}\n\n{\n\nprint x += 1\n\n}\n\nEND\n\n{\n\nprint c\n\n}'  file_cont_blkline.txt\n\n\n5) An awk script to count the total number of occurences of a pattern.\n\nawk -v ptr=0003  'BEGIN{c = 0}{c += gsub(ptr,\" \",$0) }END{print c} ' sql2.txt\n\n#here the pattern to count is '0003'  whose value is passed through variable ptr.\n\n6) An awk program to split output of netstat command into IP and port for a specific port .\n\nnetstat  -an | awk '$4 ~ \/.1521$\/ {split($5,arr1,\".\");print \"IP = \" arr1[1]\".\"arr1[2]\".\"arr1[3]\".\"arr1[4] \"|PORT = \"arr1[5]}'\n\n7) an awk program to print lines between two patterns (pattern ZO and a blank line)\nawk '$0 ~ \/ZO\/,\/^$\/{ print $0}' select_all_bRS.txt\n\n8)An awk program to write conditional output  to multiple files .\nawk '{ if ($1 ~ \/2013\/ ){ print $0 > &#8220;date.txt&#8221;} else if ( $3 ~ \/Branch\/ ) {print $0  >&#8221;brch.txt&#8221;} }&#8217; branch_dt.txt<\/p>\n<p>9) An awk script showing the use of next.<br \/>\nawk &#8216;$1 == &#8220;20130426&#8221; &#038;&#038; $7 == &#8220;04060&#8221; &#038;&#038; substr($2,1,2) == 10  {printf( &#8220;%s diff = %d \\n&#8221;,$0,$4 &#8211; $2);next }{print}&#8217; level_2.txt<br \/>\n#if next is not used then $0 will again be printed by  {print}.next skips the record<\/p>\n<p>alias<\/p>\n<p>alias<\/p>\n<p>alias is one of those commands for  people who want to be lazy. you can use alias<br \/>\nin situations where it is too time consuming to type the same commands again and again.<br \/>\nBut avoid aliases to commands like rm, kill etc.<\/p>\n<p>Example. 1)<br \/>\nTo  always use vim instead of vi, and to make sure that whenever<br \/>\n there is a  system crash, network failure etc during editing ,<br \/>\nall  the contents are recovered, use the alias as follows.<br \/>\n\/home\/viru$ alias vi  = \u2018vim \u2013r\u2019<\/p>\n<p>To make this  happen every time you work after logging in, save the above line in<br \/>\nyour .profile<br \/>\ni:e in the file  $HOME\/.profile<\/p>\n<p>after saving it in .profile do not forget to run it.<br \/>\nie \/home\/viru$ . $HOME\/.profile<br \/>\n                             |<br \/>\n                             |<br \/>\n                   a dot here is necessary.<\/p>\n<p>Example2) after running .profile ,to view all the  aliases that are set globally, just enter alias.<\/p>\n<p>\/home\/viru$ alias<br \/>\nalias ls=\u2019ls \u2013lrt\u2019<br \/>\nalias psu=\u2019ps \u2013fu $LOGNAME\u2019<br \/>\nalias df =\u2018df \u2013gt\u2019<br \/>\nalias jbin=\u2019cd \/home\/viru\/utils\/java\/bin\u2019<br \/>\nalias jlib=\u2019cd \/home\/viru\/utils\/java\/lib\u2019<\/p>\n<p>seems  viru is so lazy..!!<\/p>\n<p>Example3)<br \/>\nTo prevent  the effect of aliases defined for a word, token or a command, use unalias.<br \/>\n\/home\/viru$ unalias jbin<br \/>\n\/home\/viru$ jbin<br \/>\nJbin:not found<\/p>\n<p>There is another way to accomplish this,that is by using quotes (\u2018\u2019) after a command.the following lines show how.<br \/>\n\/home\/viru$ alias same<br \/>\nalias same=\u2019\/opt\/bin\/samefile.exe\u2019<br \/>\n\/home\/viru$ same \u2018\u2019<br \/>\nsame:not found.<br \/>\nThe effect of alias was nullified for the word same. If you use double quotes after an aliased command name ,(eg: alias df =\u2018df \u2013gt\u2019) then  the actual command will be run.(ie df\u2019\u2019 would run   \/usr\/bin\/df   instead of df  -gt)<\/p>\n<p>Aliases which are defined outside a script or in your .profile do not work inside scripts. so make sure   not to use aliased words in a shell script to contain their actual values  used outside.<\/p>\n<p>xargs<\/p>\n<p>xargs<br \/>\nXargs  is a command which can pass arguments from the output of one command to another. It can run multiline commands by passing arguments in a single file. The  most important feature is that it  creates a  list of arguments to be passed to the command and runs them.<br \/>\nExample1)<br \/>\nConsider that you have many files  and  each  have to be  renamed  with a common subscript letter.<\/p>\n<p>\/home\/Krishna $ ls    account_[0-9].txt<br \/>\naccount_4<br \/>\naccount_5<br \/>\naccount_7<br \/>\n\u2026<br \/>\n\u2026<\/p>\n<p>Then to rename  all these files  as  < filename>_old  , use xargs as follows.<\/p>\n<p>\/home\/Krishna$ ls  account_[0-9].txt  | xargs  -I  { }   mv   { }   { }_prev<br \/>\n\/home\/Krishna $ls    account_[0-9]*<br \/>\naccount_4_prev<br \/>\naccount_5_prev<br \/>\naccount_7_prev<br \/>\n..<\/p>\n<p>Here, xargs passed the output of ls, which is  a list  as  an argument list which is denoted by<br \/>\n\u2018{  }\u2019   to  the  mv  command .the  the entire line can be reconstructed as<br \/>\nmv  account_4   account_4_prev<br \/>\nmv   account_5  account_5_prev<br \/>\n\u2026.<br \/>\n..<\/p>\n<p>Example2)<br \/>\nOn few occasions, many unwanted processes  of a common type  may be running and  it is necessary to kill all of them without killing any other  process. One method would be to kill all of them with their individual PIDs, but  it may be not possible to do this in scripts, xargs does the job.<\/p>\n<p>When  it is required to kill all processes run by your login name that have names containing  ftp in it,use<br \/>\nps  -fu    $LOGNAME  |  grep  ftp  |  awk  \u2018{ print  $2 }\u2019  | xargs  -I   { }   kill  -9  { }<\/p>\n<p>Example 3)<br \/>\n You want to copy  a large number of  files  into  a directory  placing all the filenames  in a list file.<br \/>\nConsider a file containing  list of all the filenames .end line contains the destination directory<\/p>\n<p>\/home\/Krishna$ cat   candidates_logs.txt<br \/>\nArjuna.log<br \/>\nYudhistir.log<br \/>\nBhim.log<br \/>\nNakul.log<br \/>\nSahadev.log<br \/>\n\u2026<br \/>\n..<br \/>\n\/var\/tmp\/logs<\/p>\n<p>You want to copy all these files to a directory  \/var\/tmp\/logs with timestamp. use  xargs as follows.<\/p>\n<p>\/home\/Krishna$ xargs   cp  \u2013p  <  candidates_logs.txt\nThe command  structure created by xargs was\ncp  -p   Arjuna.log  Yudhistir.log  Bhim.log  Nakul.log  Sahadev.log  \u2026  candidates_logs.txt\n\nThis avoided the typing of all the files in an entire line. You may use this form of xargs in scripts where it is easier to make the list file using  simple echo and  \u201c>>\u201d .<\/p>\n<p>Example 4)<br \/>\nYou are redirecting  output containing contents of a file to another and you want a delimiting character  after every  n words , where n is any natural number, use xargs as follows.<br \/>\na point to note here is that  a word can be a single line if it contains  only one word per line.<\/p>\n<p>\/home\/Krishna$  cat   Train-Time.list<br \/>\nS29        F             12           Mumbai_CST     Karjat                   7:00pm<br \/>\nT113     F             12 (x)   Mumbai_CST     Thane                   7:04pm<br \/>\nK95        S              9 (x)      Mumbai_CST     Kalyan                  7:06pm<br \/>\nA59        S              9             Mumbai_CST     Ambernath         7:15pm<br \/>\nBL39     F             12           Mumbai_CST     Badlapur             7:17pm<br \/>\nT115     S              9 (x)      Mumbai_CST     Thane                   7:20pm<br \/>\nN27       F             12           Mumbai_CST     Kalyan                  7:21pm  <\/p>\n<p>You can use awk to delimit the fields with  a \u201c|\u201d or any other delimiting character, but  xargs can  perform it too.<br \/>\n\/home\/Krishna$ cat   Train-Time.list | xargs  \u2013n1  | xargs   -I  { }  echo  \u201c{ }|\u201d<br \/>\nS29|       F|            12|         Mumbai_CST|   Karjat|                  7:00pm|<br \/>\nT113|   F|            12|         Mumbai_CST|   Thane|                 7:04pm|<br \/>\nK95|      S|            9|            Mumbai_CST|   Kalyan|                7:06pm|<br \/>\nA59|      S|            9|            Mumbai_CST|   Ambernath         7:15pm|<br \/>\nBL39|   F|            12|         Mumbai_CST|   Badlapur|            7:17pm|<br \/>\nT115|   S|            9|            Mumbai_CST|   Thane|                                 7:20pm|<br \/>\nN27|      F|            12|         Mumbai_CST|   Kalyan|                7:21pm|  <\/p>\n<p>You can trim the ending  \u201c|\u201d character by using sed .<\/p>\n<p>Here you could have also used values greater than 1 after  n  so that the character \u201c|\u201d might be inserted after   those  many   words instead of 1.<\/p>\n<p>Example 5)<br \/>\nWhen running commands by  passing multiple arguments , it sometimes becomes necessary to interactively  ask you to run it for each argument as seen in the commands  cp  -i  and  mv  -i.<br \/>\nxargs  using  its  -p option, can perform this on any command you want to run  interactively.<\/p>\n<p>Consider a case where you need to take  tar  of files in a directory  by adding  every file  interactively  into the archive file.<\/p>\n<p>\/home\/Krishna$ ls  |  xargs   -p   -n 1   tar -cvf   \/backup\/ALL_KRISHNA.tar<br \/>\ntar -cvf   \/backup\/ALL_KRISHNA.tar  account_4_prev   ?&#8230;y<br \/>\ntar -cvf   \/backup\/ALL_KRISHNA.tar  account_5_prev   ?&#8230;y<br \/>\ntar -cvf   \/backup\/ALL_KRISHNA.tar  account_7_prev   ?&#8230;n  &#8212;&#8212;&#8212;-> your reply.<br \/>\ntar -cvf   \/backup\/ALL_KRISHNA.tar   jokes_old   ?&#8230;y<\/p>\n","protected":false},"excerpt":{"rendered":"<p>grep grep is a saviour command for unix users. grep can be used to search for patterns in a file or standard input. The pattern search includes finding the line number of the keyword, counting the number of occurrences of a keyword and many more. we will see in the following examples.<\/p>\n<p>Example 1) grep [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3509"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3509"}],"version-history":[{"count":13,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3509\/revisions"}],"predecessor-version":[{"id":3523,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3509\/revisions\/3523"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}