You are not logged in.
here is what i want to do:
cp `ls | grep -i stuff` ~/zzTMP/
but the problem is the filenames returned contain spaces and are therefore interpreted by copy as many separate files per line, none of which match. So can i somehow enclose the lines returned by grep in single quotes?
Offline
here is what i want to do:
cp `ls | grep -i stuff` ~/zzTMP/
but the problem is the filenames returned contain spaces and are therefore interpreted by copy as many separate files per line, none of which match. So can i somehow enclose the lines returned by grep in single quotes?
I would use find and xargs but if you really insist then use sed or whatever: cp `ls | grep -i stuff | sed "s/^\(.*\)\$/'\1'/"` ~/zzTMP/.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
wouldn't this be equivalent:
cp *stuff* ~/zzTMP/
or if you really need grep you could use
IFS=$'\n'; for f in `ls -1 | grep -i stuff`; do cp "$f" ~/zzTMP/; done; IFS=" "
Last edited by IgnorantGuru (2009-11-30 03:36:15)
Offline
Yeah find is probably better
find -maxdepth 1 -type f -iname "*stuff*" -execdir cp {} ~/zzTMP/ \;
Offline