question about about Bourne Shell programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thungmail
    New Member
    • Mar 2008
    • 9

    question about about Bourne Shell programming

    I would like to know what does the code below do

    #!/cs/local/bin/sh
    (cat $1; cat $2) | sort -r | uniq -d | cut -f1,4

    can anybody explain it to me
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    #2
    Originally posted by thungmail
    I would like to know what does the code below do

    #!/cs/local/bin/sh
    (cat $1; cat $2) | sort -r | uniq -d | cut -f1,4

    can anybody explain it to me
    This code gets two file names from the command prompt
    if the contents in your file $1(first arg) and $2(second arg) contains numerals or alphabets or alphanumerals they would be sorted in a reverse order listing all the lines without repetition and cut the fields 1-4 from the output(perhaps all the lines would be printed cause no delimiter is specified)

    Comment

    • gpraghuram
      Recognized Expert Top Contributor
      • Mar 2007
      • 1275

      #3
      Originally posted by thungmail
      I would like to know what does the code below do

      #!/cs/local/bin/sh
      (cat $1; cat $2) | sort -r | uniq -d | cut -f1,4

      can anybody explain it to me

      Whenever i encounter a command like this, i would break it into different commands and then see what every command does.



      Raghuram

      Comment

      Working...