trick to cp source destination & cd destinati

August 7, 2011 at 03:58:33
Specs: Ubuntu 10.10, amd

When you do a copy or move or some such operation in bash terminal., for ex.,

cp ../../folder/abc.dat ../new_folder/folder/

And now I'd like to do

cd ../new_folder/folder/

But., copy-paste is not interesting always. Probably one of the way to do this is by,
p=../new_folder/folder/ [ or p=$(pwd) or whatever]
cp ../../folder/abc.dat $p
cd $p

In other words, if I do cp source destination, how to do a cd destination by means of some
command line tricks...?

Is there any other kind of trick which is more useful and easy than the above method.

I hope someone can come up with a good answer...

With thanks and regards


See More: trick to cp source destination & cd destinati

Report •

August 7, 2011 at 08:08:56

cd ../new_folder/folder/

cp ../../folder/abc.dat . # space and a period at the end

Report •

August 8, 2011 at 04:26:12

Fine.., but let me re-frame the question. When I do,

cp source destination

,is it possible to re-use either 'source' or 'destination' as a variable with a later command? I mean, once the above command is done, say the 'source' should be assigned to 'var1', 'destination' to 'var2'. Or do we need to write a script for the same?

with thanks

Report •
Related Solutions

Ask Question