Results 1 to 10 of 11
Ok, I did this:
Code:
find . -not -name "*.mp3" -not -name "*.MP3" -type f -print >> /home/chris/fixing/tfix.txt
Now I want to cat the output of tfix.txt, and mv all ...
- 08-19-2006 #1
'mv'ing an output of cat
Ok, I did this:
Now I want to cat the output of tfix.txt, and mv all of that output.Code:find . -not -name "*.mp3" -not -name "*.MP3" -type f -print >> /home/chris/fixing/tfix.txt
Google has prooved useless, the closest I have got is this:
and using different brackets or quotabtion marks makes no difference, it just doesn't work.Code:mv (cat /home/chris/fixing/tfix.txt) /home/chris/fixing/
I have tried google, and the man pages with nothing.
Help is required,
Thanks,
weed"Time has more than one meaning, and is more than one dimension" - /.unknown
--Registered Linux user #396583--
- 08-19-2006 #2
You wanna mv tfix.txt, or each of the filenames found?
I'm confused.
- 08-19-2006 #3
for each of the filenames found.
Thanks,
weed"Time has more than one meaning, and is more than one dimension" - /.unknown
--Registered Linux user #396583--
- 08-19-2006 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
You will need to move them individually, so you might find using a for construct helpful.
Note that mv requires the new filename, so if you want it to remain intact you need to restate the original name, hence "basename $i" which will return just the basic filename, without its current path. If you don't use basename you will make copies of the subdirectories as are, which you may desire instead.Code:for i in $(find . -not -name "*.mp3" -not -name "*.MP3" -type f -print);do mv $i ~chris/fixing/$(basename $i);done
- 08-19-2006 #5
Well, first off, to use a command's output, you either use backticks (`), or, as I prefer, $(...) notation.
Now, bigtomrodney's solution will work, but I personally find it confusing. If we start off after your original find command, this would work just fine:
I personally prefer having more simpler commands over having one really complex one, so whichever of these you prefer would work.Code:exec 3< /home/chris/fixing/tfix.txt; while read line <&3; do mv "$line" "/home/chris/fixing/$(basename $line)"; done
DISTRO=Arch
Registered Linux User #388732
- 08-28-2006 #6
This should work:
(as long as there are not too many files...)Code:mv `cat /home/chris/fixing/tfix.txt` /home/chris/fixing/
EDIT: If this is anything more than a "one-time manual thing" (i.e., in a script, for repeated use) -- I would use a more structured method - handling each file separately in a loop (which is what the other guys are suggesting).
- 08-29-2006 #7
Your kidding me, that simple?!?!?
EDIT: I get no such file or directory errors on the "cat ..." section.
weed"Time has more than one meaning, and is more than one dimension" - /.unknown
--Registered Linux user #396583--
- 08-29-2006 #8
Originally Posted by Weedman
I'm not sure what you mean -- the 's' on 'errors' implies more than one error -- yet, if it was for 'cat', it would be one error - if it was for 'mv', it could be more than one error.
The contents of the file '/home/chris/fixing/tfix.txt' is assumed from your 'find' command in the first post. If the file exists, 'cat' shouldn't give an error.
If the files pointed to by the contents of '/home/chris/fixing/tfix.txt' still exist, 'mv' shouldn't give an error.


- 08-29-2006 #9
It's MV that's having the problems.
It spits out this error every time:
When I know that the files exist, and I am certain. I have checked the paths.Code:mv: cannot stat `cat ./fixing/ttfix.txt': No such file or directory
There is something wrong with the syntax, I know it.
weed"Time has more than one meaning, and is more than one dimension" - /.unknown
--Registered Linux user #396583--
- 08-29-2006 #10
This might be silly to ask, but --- You did use a backtick (`) - not a single-quote (') - before and after the cat command, right?
EDIT: I made both of the backticks BOLD - but I don't see it...Code:`cat /home/chris/fixing/tfix.txt`


Reply With Quote
