Monday, April 29, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 943  / 2 Years ago, wed, january 12, 2022, 7:55:04

I'm writing a code with fortran and I have several different output saved in different directory.



During the Do cycle I saved the temporary PATH of the output in a file.txt



Now I'm trying to plot the results runtime, but I need to enter the PATH of the output to use allways the same gnuplot script.



I want to if is possibile from terminal (shell) to enter into the PATH written in file.txt, that is read the PATH from my file.txt and enter in PATH with cd command.



I tried with cat but nothing happends!



Anyone can help me?


More From » command-line

 Answers
5

You have several ways to do this, but the idea is always the same. How to use the output of cat ?
There are 2 possible syntax, with backquotes and with $(command). I'll use the second one which is preferred (see [BashFAQ 82])



You can do it in one line



cd "$(cat file.txt)"


Or in two steps



path=$(cat file.txt)
cd "$path"

[#30234] Thursday, January 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sigtestim

Total Points: 298
Total Questions: 108
Total Answers: 106

Location: Bermuda
Member since Thu, Apr 20, 2023
1 Year ago
;