Directory_Source/file1,file2,file3,file4
Directory_Target/Combined.txt
I tried: ls Directory_Source/{file1,file3} > Directory_Target/Combined.txt
but the result inside of the txt is Directory_Source/file1
,.....
Then tried with ls -d */{file1,file3} > Directory_Target/Combined.txt
, same result.
Is it possible to achieve what I seek without changing the command? What change do I have to commit.
CodePudding user response:
Possible solutions:
ls Directory_Source/{file1,file3} | sed 's#.*/##' > Directory_Target/Combined.txt
or
basename -a Directory_Source/{file1,file3} > Directory_Target/Combined.txt
See also https://superuser.com/q/209937/992527 for more solutions.