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

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 10  |  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. If shell script file
  2. if [ '/*, *, [3,5],/d' ]; then
  3.     echo 'ok'
  4. else
  5.     echo'fail'
  6. fi
  7.        
  8. #!/bin/bash
  9. # tested with bash 4
  10. while read -r x x Y x
  11. do
  12.   case "$Y" in
  13.    "3," ) echo "ok";;
  14.    *) echo "Not ok";;
  15.   esac
  16. done < file
  17.        
  18. #!/bin/sh
  19. # let's create the input file
  20. echo '5, 2, 3, 5' > /tmp/myfile
  21.  
  22. # function will output third argument
  23. third() { IFS=', '; echo $3; }
  24.  
  25. # now let's print the third value from the input file
  26. third $(cat /tmp/myfile)
  27.        
  28. #!/bin/sh
  29. THIRD=$(awk -F', ' '{print $3}' < /tmp/myfile)