bash - How can I create directories containing file name prefixes? -


i have simple (not simple me though) question.

let's say, have a.txt, b.txt, c.txt. after repetitive processe, want save results in separate directories a_result/a_result.txt, b_result/b_result.txt, c_result/c_result.txt.

how can shell script?

thank you!

you can use ${param%word} form of parameter expansion strip .txt input file name , create corresponding directory , output file name.

for input in a.txt b.txt c.txt;     stem=${input%.txt}     mkdir -p "${stem}_result"     some_command "$input" > "${stem}_result/${stem}_result.txt" done 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -