Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. erasing with sed
  2. sed -i 's/).*/)/' file.txt
  3.        
  4. cut -d" " -f -3 file.txt
  5.        
  6. awk -F' ' '{ print $1, $2, $3 }' file.txt
  7.        
  8. cut -d " " -f -3 FILENAME
  9.        
  10. $ awk -v n=4 '{for(i=n;i<=NF;i++)$i=""}1' file.txt
  11.        
  12. $ cat file.txt | tr -s ' ' | cut -d ' ' -f 1-3
  13.        
  14. echo "a20 is (on) Jan 15" | sed 's/(s*S*){2}$//'
  15. a20 is (on)
  16.        
  17. echo "a20 is (on) Jan 15" | sed 's/(S*(s*S*){2}).*/1/'
  18. a20 is (on)
  19.        
  20. sed 's/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*).*/1/' file.txt > newfile.txt
  21.        
  22. sed -r 's/^([^ ]+ [^ ]+ [^ ]+).*/1/' file.txt > newfile.txt
  23.        
  24. cut -f-3 -d" " file.txt > newfile.txt