Thank you for the explanations. I think I'm beginning to understand it a bit better now. I work on ubuntu on the work computer so I can't really experiment right now lest I mess something up. I'm in the process of trying to install ubuntu on my laptop via virtualbox so hopefully I can start experimenting soon.
I think the work computer uses bash but I will check soon. Thank you for the instructions on how to do that.
... ... ...
I have one more question, I found this bit of commands in a tutorial that was somewhat related to my work and I was wondering if you could tell me what the command does?
Again, thank you for your assistance!
Moderator's Comments:
Please use CODE tags (not ICODE tags) for full-line an multi-line sample input, output, and code segments.
Hi,
You're welcome. First, note that the commands:
will make ABSOLUTELY NO CHANGES to any files on your system unless you remove the echo. Let me expand a little on what I said earlier: There is NO WAY to learn how to run shell commands and write shell scripts other than to run shell commands and write and run shell scripts. Run the above commands, go through the trace output line by line (referring to the bash man page) if you don't understand how the various parameter expansions are working when it is extracting the directory (dir), filename (file), the subject number (subjectnumber), and the filename extension (ext) from the pathnames (path) found by the find command, and look at the mv command that is printed by the echo command.
And, for the commands:
... I repeat: You have to run shell commands to learn what shell commands do!
And, if you try running those commands you are very likely to get a diagnostic message saying that there is no command named [bash]mv unless there is a utility named amv, bmv, hmv, smv, or [bash]mv on your system. Once you practice running commands and learn how pathname expansions work, you'll understand why I gave that list of utility names AND you'll recognize that [bash] and [/bash] are tags used in the book you were looking at indicating that stuff between those tags is a command to be given to the bash shell command language interpreter; not part of the text of the commands themselves.
Note however, that running a mv command will actually move files. So do this in a directory with test files you have set up with matching names; do not try this in a directory where you have files with names ending in .bvec or .bval and directories named bvecs and bvals unless you actually want to move all of the files with names ending in .bval to the directory named bvals and want to move all of the files with names ending in .bvec to the directory named bvecs.
If those directories don't exist, what happens will vary depending on how many files match those filename patterns. Why don't you look at the mv man page and tell me what will happen in each of the following cases when you run the command:
and:
no file matches the pattern *.bvec and there is a directory named bvecs,
no file matches the pattern *.bvec and there is a regular file named bvecs,
no file matches the pattern *.bvec and there is no file named bvecs,
one file matches the pattern *.bvec and there is a directory named bvecs,
one file matches the pattern *.bvec and there is a regular file named bvecs,
one file matches the pattern *.bvec and there is no file named bvecs,
two or more files match the pattern *.bvec and there is a directory named bvecs,
two or more files match the pattern *.bvec and there is a regular file named bvecs, and if
two or more files match the pattern *.bvec and there is no file named bvecs.
Hi,
I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern.
Note:These are the samples of two files,but i can have more... (2 Replies)
Hello,
i wanna rename my files which names are written in movies.txt
films.txt = amovie
bmovie
cmovie
dmovie
emovie
and i wanna find this files and rename the files to 1_amovie
... (12 Replies)
I want to rename the files by taking part of the file and appending date to it. please help
e.g.
abc-390.csv
xyz-908.csv
desired format is abc_YYYYMMDD.csv
This is what I have but it is not working
for each in *.csv;
do
mv $each /abc/data/"`date '+test_%Y%M%M'`".csv
done (2 Replies)
Hi,
I have a very urgent requirement here. I have to find all files in the specified directory but not in the sub directories(The directory name is stored in a variable) which are older than the current date as well as current time and rename it as filename_yyyymmddhhmmss.ext and move it into a... (7 Replies)
Hello,
I wanted to rename one file where filename contains space.. How can i rename in unix?
The file name is ABC XYZ.TXT
I wanted to rename this file as ABCXYZ.TXT.
Any help is greatly appreciated...
Regards. (4 Replies)
Hi All
I have a folder that contains hundreds of file with a names
3.msa
4.msa
21.msa
6.msa
345.msa
456.msa
98.msa
...
...
...
I need rename each of this file by adding "core_" in the begiining of each file such as
core_3.msa
core_4.msa
core_21.msa (4 Replies)
Hi
i have to achieve the following
i have files as xyz001.csv, xyz002.csv.......xyz0025.csv in a folder, i need to keep xyz001.csv as it is
but want to remove the extra zero on filename from 10 say
xyz0010 should be renamed to xyz010
xyz0025 should be renamed as xyz025
Note xyz... (8 Replies)
Hello,
I am looking for a command line that will rename name files :
f700_abc_o_t_MASTERID_AS_AE_20130323.csv
like this
f700_abc_o_t_MASTERID_AS_AE_20130324.csv
The great idea could be to get the date stamp 20130323
and change any part of it, instead of just change the... (4 Replies)
Hi,
In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this?
I am using #!/bin/ksh
For eg: sftp user@host <<EOF
cd /path
get *.txt
rename *.txt *.txt.done
... (7 Replies)