Hi All
How can I add .txt or .fa extension to multiple 'Unix Executable' sequence files using terminal?
Thanks!
Hi All
How can I add .txt or .fa extension to multiple 'Unix Executable' sequence files using terminal?
Thanks!
Thank you all!
The following worked -
for i in *; do mv "$i" "$i.txt"; done
It's from here - http://osxdaily.com/2012/11/22/add-file-extension-group-of-files-os-x/
the for loop is POSIX compliant. if by unixy you mean meaninglessly verbose with no added benefit to readability or speed, then i must respectfully disagree :) i mean why not:
find ./ -maxdepth 1 -type f | xargs -n -P "$(grep -c ^processor /proc/cpuinfo)" -iFILES sh -c 'mv FILES FILES.txt'
instead of:
rename 's/$/.txt/g' ./*
It took me a 10s longer to write the first one, even if it's 0.001ms faster than rename. :D
How is it needlessly verbose? That's why I said "in my opinion", because I find the find (heh) – and even the xargs – solutions more intuitive and, frankly, faster to type. i.e. I'm too good with Unix that it wouldn't take me 10 more seconds to come up with and execute you're exaggerated "verbose" example over the rename one. :D
We could keep discussing the best way to do this, but as long as they work, it's no big deal. For example, I use xargs
and not -exec
because of the -I
option which gives me a lot more freedom to work with different types of values passed on by find, but I don't say it is objectively better, just that it works for me.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
you don't because you don't understand what you're doing :-)
please show us a example of input/output.
Can you be a little clearer about what you want to do and why?
A binary file is compiled byte code. It will always be interpreted as byte code regardless of what extension you put on it. Extensions really don't mean that much in linux, and that's especially the case for bash and sh.
If what you want to do is simply rename a file you can:
But I'm still not clear on why.
Hi mforde84 and Pierre
I split one single file FASTA file with 100 reads (a subset from 75000+ reads; post merging and QC) into one hundred separate files, with one sequence each using
faSplit
. However, I could not give an extension to the one hundred split files, in absence of which on my mac they were visible as Unix Executable files. But the following, posted below, worked!Thank you.