You are not logged in.
Pages: 1
I only want to copy files...
when you copy the entire content of a directory which contains files and subdirectories, you get the following message (without recursion of course):
cp: omitting directory `blablabla'
is there a way to "mute" this message? i know i can redirect stdout and stderr, but i thought there must be a more efficient way. or better yet can i supply all the normal files in the dir as cp's arguments instead of *? if so, how?
thanks
Offline
What is inefficient about redirecting stderr? Apart from obviously missing out on any other error messages...
Can you give us an example of the problem -- I don't quite understand what you're trying to achieve...
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
i'm trying to copy all the files in a directory without copying the sub-directories
examaple:
[sulaiman@PINK ~]$ mkdir ./tester
[sulaiman@PINK ~]$ mkdir ./tester/sub-test
[sulaiman@PINK ~]$ mkdir ./tester/sub-test2
[sulaiman@PINK ~]$ cd tester
[sulaiman@PINK tester]$ touch a s d f g
[sulaiman@PINK tester]$ ls
a d f g s sub-test sub-test2
[sulaiman@PINK tester]$ cp * sub-test
cp: omitting directory `sub-test'
cp: omitting directory `sub-test2'
[sulaiman@PINK tester]$
i don't want to copy the dirs in the first place but specifying the files one by one is not an option
Offline
Offline
wtf?!!
Offline
guys, seriously.. i need to know.
ps: funny, just got it. nice one bangkok_manouel
Last edited by SIGTERMer (2009-03-20 07:22:49)
Offline
For example... but do a more work, many syscalls.
find -maxdepth 1 -type f ! -name '.*' -exec cp {} hola/ \;
hola/ is a directory.
! -name ',*' omits dot-files (hidden files)
-type f only find regular files
-maxdepth 1 , don't recurse
The "osito" is funny hahah
(osito == bear)
Offline
see above
Last edited by fumbles (2009-03-20 07:43:51)
Offline
from the looks of it, i'll go with redirecting. loops & find are the exact opesite of what i was looking for. but thanks anyways
Offline
I see what you did there
Offline
Sandman, I just have to ask. I have been struggling to figure out your avatar now for quite some time.
Is it a fist wrapped in bandages?
Offline
from the looks of it, i'll go with redirecting. loops & find are the exact opesite of what i was looking for. but thanks anyways
You could just create an alias for the command suggested above your post, and then use that if you don't like to miss other errors.
alias cpnd="find -maxdepth 1 -type f ! -name '.*' -exec cp {} hola/ \;"
Hmm... now that I look at it, the alias is not correct. Maybe a bash script would be better, though.
Last edited by foxbunny (2009-03-20 13:27:41)
Offline
I still don't get this completely.
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
Offline
bangkok_manouel wrote:I still don't get this completely.
http://www.youtube.com/watch?v=dh6wtATgJRs & touch(1)... you put them together
why am i feeling like a 12 year old?
Last edited by SIGTERMer (2009-03-20 17:19:16)
Offline
haxit wrote:bangkok_manouel wrote:I still don't get this completely.
http://www.youtube.com/watch?v=dh6wtATgJRs & touch(1)... you put them together
why am i feeling like a 12 year old?
That is what I thought....
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
lol @ pedobear
reminds a bit of the "Sexual Harassment Panda" from South Park
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
+1 Bangkog_manouel
Hello SIGTERmer this is the behaviour of cp and google search will give tons of results One way to avoid this error is to redirect the error as fukawi2 said. The other way is to write your own bash script. I wrote a quick script and if you need you can polish it.
Note: For directory entry don't use any / or wild card characters at the end ie blah/* or bla/ only use path/to/directroy
#! /bin/bash
# copies only files from the source directory
# to the target directory....
#
#checks the source and Target
#
if [ "$1" == "" ] && [ "$2"=="" ];
then
echo " Usage: cpnd <Source Directory> <Target Directroy> "
exit 0
fi
if [ ! -d $1 ] ;
then
echo " $1 is not a Directory"
exit 1
fi
if [ ! -d $2 ];
then
echo "$2 is not a Directory"
exit 2
fi
echo Preparing for copying....
Target=$2
for x in $(ls $1);
do
source=$1/$x
if [ ! -d $source ]; then
cp $source $2
fi
done
echo File copying completed...
exit 0
.
Last edited by kgas (2009-03-21 12:35:58)
Offline
+1 Bangkog_manouel
Hello SIGTERmer this is the behaviour of cp and google search will give tons of results One way to avoid this error is to redirect the error as fukawi2 said. The other way is to write your own bash script. I wrote a quick script and if you need you can polish it.
Note: For directory entry don't use any / or wild card characters at the end ie blah/* or bla/ only use path/to/directroy#! /bin/bash # copies only files from the source directory # to the target directory.... # #checks the source and Target # if [ "$1" == "" ] && [ "$2"=="" ]; then echo " Usage: cpnd <Source Directory> <Target Directroy> " exit 0 fi if [ ! -d $1 ] ; then echo " $1 is not a Directory" exit 1 fi if [ ! -d $2 ]; then echo "$2 is not a Directory" exit 2 fi echo Preparing for copying.... Target=$2 for x in $(ls $1); do source=$1/$x if [ ! -d $source ]; then cp $source $2 fi done echo File copying completed... exit 0 .
kgas, i was looking for something more in the line of * (a wild card for regular files) but it seems that the most officiant way is to simply copy everything and ignore the warnings (/dev/null). but thanks anyways
Offline
Pages: 1