Glam Prestige Journal

Bright entertainment trends with youth appeal.

Let's say, under this directory: /home/data/

There are 100 folders, the name of these folders are 24538_7#1, 24538_7#2, 24538_7#3 ... to 24538_7#384.

In each folder, there are many files and folders.

The names of the desired file in each folder is Aligned.out.sam The desired folder for renamed files is /home/SAM

How can I copy all these files to the new folder(/home/SAM) and rename them properly as 24538_7#1.sam, 24538_7#2.sam, 24538_7#3.sam ......?

I tried doing it by the command below but it didn't work:

mv /home/data/*/Aligned.out.sam /home/SAM/*.sam

9

1 Answer

Something along the lines of

for sam in */Aligned.out.sam; do \ name=$(basename $(dirname "$sam")) \ cp "$sam" "/home/SAM/$name.sam" \
done

might do the trick

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy