0
I am new to Linux and have been using the cd command for a while. I just saw someone cd'ing to somefolder/* like cd foo/*
. What does that do?
Also, depending on how that works, what will be the outcome of cp -R foo/* bar
?
Edit- If cd foo/*
cd's into the first directory inside foo, shouldn't cp -R foo/* bar
only copy the first directory present inside foo to bar?
so shouldn't cp -R foo/* bar only copy the first directory inside foo to bar ? – aandis – 2014-06-12T10:34:10.013
No, that will copy all of them. When you use
*
on the shell, press Ctrl+X and then*
instead of pressing Enter, this will expand the*
and show you what will actually be executed. – Der Hochstapler – 2014-06-12T10:36:12.6501The difference is that
cp
takes multiple arguments (filenames) andcd
only takes a single argument. When the shell expands multiple filenames,cd
will take the first. – mtak – 2014-06-12T10:53:43.803