vendredi 30 janvier 2015

List the files of another format while finding a certain name pattern


I had wanted to edit the txt files of videoA and videoB only if the movs files names contains the namespace -test


For eg.



videoDir
|-videoA
|- videoA_v001_test.mov
|- videoA_v001_info.txt
|-videoB
|- videoB_v001_test.mov
|- videoB_v001_info.txt
|-videoC
|- videoC_v002.mov
|- videoC_v002_info.txt


Above, I want to edit videoDir/videoA/videoA_v001_info.txt and videoDir/videoB/videoB_v001_info.txt but not videoC_v002_info.txt since the corresponding .mov file name doesn't contain test.


I come up with the command - find -name "*.mov" | grep -rn "test" | find -name "*.txt", find -name "*.mov" | grep -rn "test" does indeed lists out the 2 files that fulfills the condition (videoA and videoB). I added infind -name "*.txt"` as I had thought it will filter it down to the txt files within the output results, however I was wrong as it is still listing all the txt files



Aucun commentaire:

Enregistrer un commentaire