#Shell script to manage files

1 messages · Page 1 of 1 (latest)

twin forge
#

There are a few ways to do this, but I think the first thing that should be asked is if you care that it's a shell script or if using something else would be fine. (I.E python).

If this is for a class assignment or something where you have to use a shell script, you can use grep to find lines that begin with Organism and/or use sed to do something like s/Organism:([\S]+)^/\1/ as a regular expression to capture the directory name, and a similar regular expression can be used to snag whatever you want from the header.
There are probably like 50 ways to go about this though.

fast jetty
#

@mild moon

Hello everyone, I am trying to learn linux basics if anyone could give me some guidance on what to do.

I have a bunch of same type text files with random names that I would like to manage more orderly. They are all files structured such as the one attached.

I would like to make a shell script that:

  • reads the files one by one
  • sorts them into new folders, according to the organism

so for this one it would create a folder Mus musculus and put any following files with organism: Mus musculus in that as well, same for other types of organisms)

  • also renames the files into the information displayed in the header, or just the first top line if that would make it simpler

If you have any tips or commands or example scripts that could help me for any of the parts I would really appreciate it, have been trying to figure something out for hours but am very much out of my depth here 😅

https://media.discordapp.net/attachments/1042230098222395443/1042230098746679387/files.jpg