jmunsch

bash for iterate

Nov 7th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. # bash for loop example
  2.  
  3.  
  4. LIST=(
  5. some
  6. thing
  7. )
  8.  
  9. for item in ${LIST[@]};do echo $item;done
  10.  
  11. for item in ${LIST[@]};do sudo grep -R $item . >> ../RELIST;done
  12.  
  13. # bash for iterate download urls
  14. for item in ${LIST[@]};do mkdir ./item/${item:0:5} && wget -O ./item/${item:0:5}/${item}\.html http://example.com/product/${item:0:5}\.uts;done
  15.  
  16. # grep -oh keep only the found characters
  17. for item in ${LIST[@]};do grep $item ../RELIST | grep -oh ",[0-9]*\.[0-9][0-9],";done
  18.  
  19. for item in ${LIST[@]};do temp=$(grep $item ../RELIST);echo $(echo $temp | grep -oh ",[0-9]*\.[0-9][0-9],") $item >> OUTPUT;done
Advertisement
Add Comment
Please, Sign In to add comment