lundi 16 février 2015

Reuse output from command 1 in command 2 using a pipe


I've got a command in linux which returns a list of numbers. Now I need this numbers to form a directory path and cat the file located at that path. For example: myCommand returns:



1
10
30
40


And I want to cat all the files that look like this:



/folder/1/folder2
/folder/10/folder2
/folder/30/folder2
/folder/40/folder2


I Hope it is clear what I want, if not, feel free to ask. This is my code right now:



myCommand | xargs cat


But it obviously doesn't work since directory 1,10,30 and 40 doesn't exist.


I want the output to be: the catted value - number generated by myCommand



Aucun commentaire:

Enregistrer un commentaire