I think I know what has happened. Not good I'm afraid.
If the value of $dir was not the name of a directory, the "mv" command will assume that it is a file ... and create it.
Unfortunately every file in your current directory with a day-of-month field of "12" has been moved to the same file. That file has the name of the directory that didn't exist. The only file which is salvageable is the last file which was moved (as long as you know what the name of the file was).
(Prefix: Sorry, I do not understand you last post #5 at all. Please write again in better English. This is not an answer to your last post, it is an answer about how to find the file which was created).
In this context I've assumed that directory "/abc" exists or the "mv" command would have failed.
This should provide the answer.
Or:
Or:
All of which should give the same result.
ANALYSIS of Post #5
Quote:
thanks for ur reply
i got it
only the last file is moved to a $dir(a file being created)......
i hv another doubt
suppose my $dir is like /abc/def/
should i provide "/abc/def/" or "/abc/def/." in my command
1) ALL your files dated day "12" (in any month and in any year) got moved to the single named file when $dir was not a directory.
Only the last file to be moved was not overwritten. It was a disaster. We hope you were just testing.
2) When $dir is a directory, the best format is "/abc/def/" . Get into the habit of putting double quotes round strings. One day it will save you.
3) I have real trouble reading text speak ! Words like "ur" and "hv".
suppose like i have 26 files named a.txt,b.txt,c.txt,....y.txt,z.txt
i have to move them to a directory /dir1/dir2/dir3
but by mistake dir3 does not exists
i executed
then a file named dir3 is created in directory /dir1/dir2/
which is nothing but z.txt
---------------------
and my doubt was what is the difference in below two
Last edited by Franklin52; 12-13-2011 at 04:08 AM..
Reason: Please use code tags for code and data samples, thank you
Hi,
I am working on a file copier utility where I have written the copy commands to a batch file e.g. file_copier.bat which i pass to xargs command as follows.
cat file_copier.bat | xargs -n 1 -P 40
I also want to record the copy command status of each file/command in the form "command... (1 Reply)
ls | grep -E '^+$' | xargs --verbose -I{} rm -vfr "{}";
When i execute the command it works fine by removing the directories and its writing the output as below about which files are deleting.What i want know is,is there any XARGS command option that it should done silently in background with... (2 Replies)
xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it.
$ scr.sh
gives output like
193740
638102
375449
..
..
another command takes these number as inputs. it works great... (1 Reply)
Hi,
What is the difference in capitalizing the option 'i' of xargs command, (i.e) xargs -i and xargs -I?
Also, what is the difference between the below 2 commands?
output_from_cmd | xargs -I {} grep '{}' file
output_from_cmd | xargs -I grep '{}' file
Any efficiency or performance... (4 Replies)
Hi
The command below does not work. what I am doing wrong ?
For some reason second part of the xargs command is not does what I expect
If I get this working I intend to use it for multiple file rename later.
echo archDP105144_1_702159963.dbf|xargs -i cp {} `echo {}|awk... (11 Replies)
Hi
I am trying to use "xargs" command to loop through each file, modify it and overwrite the old file with the modification but with the same file name.
I thought it is easy but I just can't get it to work
I tried the following
I thought {} would give me the current file name, but it... (1 Reply)
what is the real use of xargs command ..?
ls -tr |xargs -I{} rm -f {}
....can any one tell me what is the significance of {} curly brackets in this command (1 Reply)
my task : tar up large bunch of files(about 10,000 files) in the current directories that created more than 30 days ago
but it come with following error
find ./ -ctime +30 | xargs tar rvf test1.tar
tar: test1.tar: A file or directory in the path name does not exist. (3 Replies)
Hello,
I'm on a mac trying to have the follow cmd list the files after touch, but very unsuccessful. Please can you help.
sort $BOTHFILE | uniq -u | xargs -I {} -t touch {} >> $LOGFILE ;
BOTHFile contents in form of
/directory/file.txt
thanx (3 Replies)
Hi Everybody,
Can you explain the difference between the following commands:
1. find . -print|xargs grep -i dba_2pc_pending
2. find . -print|grep -i dba_2pc_pending (5 Replies)