I have two text file like this:
list.txtfile 'aavr-001-1.mp4' file 'aavr-001-2.mp4' file 'aavr-001-3.mp4' file 'ccr-010-1.mp4' file 'ccr-010-2.mp4' file 'ccr-010-3.mp4' file 'vvvw2-031-1.mp4' file 'vvvw2-031-2.mp4'
code.txtaavr-001 ccr-010 vvvw2-031
My code:
for f in $(cat code.txt); do
s=$(echo $f)
cat list.txt | sed '/$s/!d' >$s.txt
done
I was expecting to get these three files with the following content:
aavr-001.txtfile 'aavr-001-1.mp4' file 'aavr-001-2.mp4' file 'aavr-001-3.mp4'
ccr-010.txtfile 'ccr-010-1.mp4' file 'ccr-010-2.mp4' file 'ccr-010-3.mp4'
vvvm2-031.txtfile 'vvvw2-031-1.mp4' file 'vvvw2-031-2.mp4'
But in the end I could only get three blank files: aavr-001.txt ccr-010.txt vvvw2-031.txt, not any content in them.
What should I do to fix the problem?
p.s. If I only input like cat list.txt | sed '/aavr-001/!d' >aavr-001.txt, I can get the result I want