Date: Wed, 1 Oct 2003 13:59:16 -0700 (PDT) From: Viktor Lazlo <viktorlazlo@telus.net> To: Dan Nelson <dnelson@allantgroup.com> Cc: freebsd-questions@freebsd.org Subject: Re: newbie question - how to pass textfile as an argument Message-ID: <20031001134219.P8342@njamn8or.no-ip.org> In-Reply-To: <20031001203209.GA2421@dan.emsphone.com> References: <20031001232109.0ae5bfd4.martin.vana@vslib.cz> <20031001203209.GA2421@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 1 Oct 2003, Dan Nelson wrote:
> In the last episode (Oct 01), Martin Vana said:
> > I was just wondering if there is a way how to pass a text file with
> > list of path/files to programs like cp/mv.
>
> If the list is small (less than 65000 characters total):
>
> cp $(cat myfile) /otherdir/
>
> If the list is large:
>
> xargs < myfile -J% cp % /otherdir/
You could also run it through a for loop:
for i in $(cat myfile); do mv $i ~/mydir; done
Or if the files can be grouped by a pattern:
for i in *.mp3; do mv "$i" ~/mymp3s; done
Or if the files are scattered all over your hard drive and you haven't
created a list yet:
find / -type f -name "*.mp3" -exec mv {} ~/mymp3s \;
Cheers,
Viktor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031001134219.P8342>
