Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to copy between folders and parent folder without complete path

This is a basic question but I am struggling to find a decent solution. This is hindering my script from automation.

I have the following path.

/home/hassan/Dyna/ProjectSimulation

in project simulation I have 3 folders

friction time force

like

/home/hassan/Dyna/ProjectSimulation/friction

Now I have a file friction1.txt in this friction folder and I want to copy it to ProjectSimulation.

is it possible to avoid complete path and just one step down?

Also if I have to copy this friction1.txt to folder force, is there anyway to avoid the complete path.

I mean I have a subroutine but this is path dependent , whenever I run it , I have to run in the same folder and then copy my results so I can run only one instance of my simulation.

Experts please guide me.

PS: This is part of a 600 lines shell.

like image 628
hamad khan Avatar asked Mar 29 '12 15:03

hamad khan


1 Answers

This comes across as so basic that I must have misunderstood something in your question.

If you want to refer to a parent directory, .. is the way to do that. So, if you want to copy friction1.txt to two places you just do

cp friction1.txt ..
cp friction1.txt ../force

All you need to take care of is making sure that CWD is

/home/hassan/Dyna/ProjectSimulation/friction

so that the references point at the right place.

like image 71
HonkyTonk Avatar answered Nov 15 '22 17:11

HonkyTonk