I don't understand what you're asking about fortran code, but getting sets of 3 files in sorted order in the shell is not hard. This doesn't do anything very useful, but may be a suitable example to show you what needs to be done to meet your requirements:
Note that this won't work if any of your *.txt filenames contain whitespace characters, and will silently ignore the last one or two *.txt files if the number of *.txt files is not an integral multiple of 3. In a directory containing the files:
this script produces the output:
This User Gave Thanks to Don Cragun For This Post:
Thank you so much
My .for code looks like this...
for each text file here I have to replace inp and outfile every time, if many files means its time consuming
if it was shell I would have done
So I am just wondering some provision to use bash variables in place of inpfile and outfile in .for code
I assume that you want your Fortran code to be able to look at its command line arguments rather than recompiling your source with different values for input and output filenames derived from shell variables at compile time.
If your Fortran compiler complies with the 2003 Fortran standard, try accessing the comand line arguments as specified here: GET_COMMAND_ARGUMENT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
See also related intrinsic for f77:
Quote:
]8.98 GETARG - Get command line arguments
Description:
Retrieve the POS-th argument that was passed on the command line when the containing program was invoked.
This intrinsic routine is provided for backwards compatibility with GNU Fortran 77. In new code, programmers should consider the use of the GET_COMMAND_ARGUMENT intrinsic defined by the Fortran 2003 standard.
...
Cope sample1: test.sh
i=0
echo " Outside loop i = $i "
while
do
i=$(( $i + 1))
echo "Inside loop i = $i "
done
echo " Out of loop i is : $i "
When run output :
Outside loop i = 0
Inside loop i = 1
Inside loop i = 2
Inside loop i = 3
Inside loop i = 4
Inside loop i = 5
Inside... (8 Replies)
I have the following while loop that I put in a script, demo.sh:
while read rna; do
aawork=$(echo "${rna}" | sed -n -e 's/\(...\)\1 /gp' | sed -f rna.sed)
echo "$aawork" | sed 's/ //g'
echo "$aawork" | tr ' ' '\012' | sort | sed '/^$/d' | uniq -c | sed 's/*\(*\) \(.*\)/\2: \... (3 Replies)
I have a bash loop that waits for a single key press, then does $something depending on what $key is pressed before refreshing the screen with updated data. The problem I have is that the script will store additional key presses and chain them together causing the screen to redraw and the script... (1 Reply)
Hi ALL,
I always use du command for analyzing diskusage to housekeep a filesystem.
Can somebody tell the where first row filesize resides?
bash-3.2# df -gt /tmp
Filesystem GB blocks Used Free %Used Mounted on
/dev/hd3 16.50 10.01 6.49 61% /tmp
bash-3.2#
bash-3.2# pwd... (6 Replies)
Hi all ,
i want to pass multiple files as input to a for loop
for i in file1 file2 file3
do
some awk action < $i >> $i.out
done
but im getting error in that for loop is the way i use to pass files to awk using for correct and
2.we can directly pass multiple files to awk as... (7 Replies)
Hi,
I have a loop running until a variable L that is read previously in the full script. I'd like to grep some information in an input file at a line that contains the value of the loop parameter $i.
I've tried to use grep, but the problem is nothing is written in the FILE files. It seems grep... (5 Replies)
I would like to write a for loop that does the following:
I have a file called X.txt and other files called 1.txt,2.txt, .....,1000.txt.
I want to substitute the 6th column of the file X.txt with 1.txt and store the output as X.1. Then I want to do the same with X.txt and 2.txt and store the... (1 Reply)
Hi,
I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh).
The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Hi,
I have a .test file which has:
#!/bin/ksh
export TEST_FLAG=1
In the test1.ksh i have:
#!/bin/ksh
. .test
echo $TEST_FLAG
When i execute the test1.ksh its showing the value as 1.
But if i refer the same variable in another script, the value is not 1.
Basically, I need to have... (1 Reply)
Hi! I have a simple question about using a for loop.
I'm trying to open up all the zip files in the currect directory with ark, but I am getting the error "bash: syntax error near unexpected token `for $i ; do ark $i ; done ;
I looked in the info pages for bash, but I can't seem to figure... (2 Replies)