fork download
  1. #!/bin/bash
  2. cd $(mktemp -t -d) # this is specific to ideone, don't reuse it
  3.  
  4. touch 0_a_0 0_a_1 0_b_0 0_b_1 # create sample files
  5. mkdir toto # create target directory
  6. echo """a
  7. 1""" > inputFile # create an input file with tokens 'a' and '1'
  8.  
  9. ls -Al .; echo "Input file : "; cat inputFile # shows us what we've got
  10.  
  11. while read searchToken; do
  12. for file in ./*$searchToken*; do
  13. cp $file toto
  14. done
  15. done < inputFile
  16.  
  17. echo "Result :"; ls -Al toto # and here is the result
Success #stdin #stdout 0s 5080KB
stdin
Standard input is empty
stdout
total 4
-rw-rw-r-- 1 20097 1001  0 Aug  2 14:57 0_a_0
-rw-rw-r-- 1 20097 1001  0 Aug  2 14:57 0_a_1
-rw-rw-r-- 1 20097 1001  0 Aug  2 14:57 0_b_0
-rw-rw-r-- 1 20097 1001  0 Aug  2 14:57 0_b_1
-rw-rw-r-- 1 20097 1001  4 Aug  2 14:57 inputFile
drwxrwxr-x 2 20097 1001 40 Aug  2 14:57 toto
Input file : 
a
1
Result :
total 0
-rw-rw-r-- 1 20097 1001 0 Aug  2 14:57 0_a_0
-rw-rw-r-- 1 20097 1001 0 Aug  2 14:57 0_a_1
-rw-rw-r-- 1 20097 1001 0 Aug  2 14:57 0_b_1