Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Bugs & Fixes 3 years ago
User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
I've adjusted some of your variable names a bit.
Surely there are better ways to do this than something dangerous like parsing the output of ls, but see whether this works for you:
$ pth="/projects/ox/git"
$ server="myusername@server"
$ dir="$(ssh $server "ls -t \"$pth\" | head -1")"
$ mkdir -p "$pth/$dir"
$ scp -p $server:"$pth/$dir"/'*_out.csv' "$pth/$dir"/
Once dir has been set to the newest remote directory, mkdir -p is used to ensure that the same directory name exists locally. Then scp the files into a local directory with the same path and name as the remote directory. I was looking for an rsync solution, but couldn't think of one.
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
manpreet
Best Answer
3 years ago
I'm writing a bash script that needs to fetch all
*_out.csvfrom a directory, on a remote server. All these files are several directories deep inside of another directory. So for instance, say the directory is calledox_20190404/. I can find all my files by going:find ox_20190404/assessment/LWR/validation -type f -name "*_out.csv"
This question answers part of my question, but since I don't want to copy the directory in it's entirety I need to figure out how to implement the above code. Suppose I start with this:
How would I grab the f="https://forum.tuteehub.com/tag/file">files I need from there?
The last part of my question wonders if there is a way to then take all the copied f="https://forum.tuteehub.com/tag/file">files and place them in the same f="https://forum.tuteehub.com/tag/file">file path and directory they were in on the remote server.