Re: Scripting names from a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2004-09-28 at 09:53, Chadley Wilson wrote:
> On Tuesday 28 September 2004 16:41, Filippos Klironomos wrote:
> > > Lets say for example I have a text file with one name on each line and I
> > > need to create files based on the names in that file, If I can use a for
> > > loop it would be greate, but I don't know how to get each name from the
> > > file,
> >
> > You don't need a script for that. Something simple as:
> >
> > cat file_with_filenames | xargs touch
> >
> > will just create those filenames in the file file_with_filenames but
> > of course they will have zero size. So you have to be more specific on
> > what you want to do with those file names.
> OK Maybe I am trying to be too clever in my simplification of the senario, so 
> maybe this helps:
> I have a directory with files in it, I also have a text file with a list of 
> certian files, I need to mv the files listed in the text files out of the dir 
> into a new dir which I have created.
> Does that make more sense?
> 
> So basically I am after something like this
> for i in `each_name_in_file ` ; do
> mv $1 /dest/dir
> done
> 
> 
for i in `cat file_with_names` ; do
mv $i /dest/dir
done 

should do the trick for all files listed in the file.
You may wish to add a -f (force) option to the move command to avoid
nasty notes if the file does not exist or if it cannot be moved for some
reason.


> The bit I can't workout is `each_name_in_file `
> 
> Thanks
> -- 
> Chadley Wilson
> Redhat Certified Technician 
> Cert Number: 603004708291270
> Pinnacle Micro
> Manufacturers of Proline Computers
> ====================================
> Exercise freedom, Use LINUX
> =====================================


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux