After looking at the differents post on this forum, I am convinced that I will benefit from the experience of advanced Unix user on some script I have already done for an aeronautical study. Here is one of them :
Step 1 :
with Base_Awk.txt :
Step 2
To summarize, I have 7 x 70 files Cut_1??.txt,Cut_2??.txt,...,Cut_7??.txt and the output is 70 files ordered with the awk command (line 1 file Cut_101.txt line 5001 Cut_2??.txt and so on to Cut_7??.txt line 30001).
I have obtained this results with the code above, I was wondering if i could bypass the script with the sed replacement and using variables in the awk command, something like that (I know it won(t work just for the idea) :
I have seen on this forum the use of variable in Awk but have been unable to use it for this script.
If anyone can lend me a hand on this one, I would be much grateful.
Why don't you run the loop within awk to be more efficient?
I'm sorry I don't absolutely understand what you are heading for, but I'd bet there would be more efficient ways to achieve your goals. We could help if you'd post sample input and desired output files and the logics that connect them.
I have attached the maximum of 5 files per post but it will be enough I hope.
The Cut_?0?.txt files are the input, as output for this example let's say I want the Desired_Output_Cut_01(Cut_101_Cut_201).txt file and another which would correspond to Cut_02 with Cut_102.txt and Cut_202.txt at line 50 concatenated.
In fact, the first digit match an envelop of loadcase (?01), the last two digit correspond to a cut to obtain the flux in the area (1??). On the real study, I have obtained the correct output with the scripts enclosed in the first post but as RudiC pointed out a loop like the one described in the end of my first post is the code I would like to see working. It might spare me a lot of time. I have not been able to use variable in the loop (Thanks CarloM for the syntax).
Sorry, still not clear. Your Desired_Output_Cut_01(Cut_101_Cut_201).txt is just a concatenation of two of the input files. You don't need awk for that.
If I read your approaches in post#1 correctly, you have a file and want the cut- files inserted every 5000 lines? How's all that connected to Base_Awk.txt and Fichier_Base.txt?
Re-reading myself, I reckon I have been difficult to understand.
As Input, let's say I have 90 files named Cut_£??.txt (with ?? matching the cut from 01 ->10 and £ matching the envelop from 1 ->9).
I want as output; 10 files one per cut and in each one a cat of the different envelop with the awk command to have the different envelop at the correct line.
I did that with the sed script and the Base_Awk.txt of Step 1, the Fichier_Base.txt file is an empty file with 50 000 line because I did not manage to insert a file at line 25000 for example when the input file was not 25000 line long.
Hi,
I have a file(testfile.txt) that contains list of variables as shown below. T
$$FirstName=James
$$LastName=Fox
$$Dateofbirth=1980-02-04
……and so on there are 50 different variables.
I am writing a script(script1.sh) that will update the above three variable one by one with the values... (6 Replies)
Hello I am hoping you may help.
I am not sure how to go about this exactly, I know the tools but not sure how to make them work together.
I have two SED commands that I would like to run in a shell script. I would like to take
the manual input of a user (types in when prompted) to be used... (4 Replies)
I am trying to print text between two variables in a file
I have tried the following things but none seem to work:
awk ' /'$a'/ {flag=1;next} /'$b'/{flag=0} flag { print }' file
and also
sed "/$a/,/$b/p" file
But none seem to work
Any Ideas?
Thanks in Advance (5 Replies)
hi guys,
The following command doesn't seem to work in my shell script:
tag=$(sed -n '/${line}/ s/.*\.*/\1/p' myfile.txt)
When i replace the ${line} with an actual value, it works fine.
So, how do i use the ${line} in this sed command?
Thanks in advance,
Zaff (2 Replies)
Can I use my own variables within awk and sed for example:
I've written a while loop with a counter $i and I want to use the value of $i within sed and awk to edit certain lines of text within a data file.
I want to use :
sed '1s/$/texthere/g' data.csv
Like this:
sed '$is/$/$age/g' data.csv... (5 Replies)
Hello,
I wonder if it is possible to pass and use variables from shell environment into sed or awk. I am trying to achieve something similar to the following using sed or awk:
var=some_regular_expression
grep "$var" filename # Will extract lines from filename
The following code,... (3 Replies)
Hi all-
I've been fooling with this for a few days, but I'm rather new at this...
I have a bash variable containing a long string of various characters, for instance:
JUNK=this that the other xyz 1234 56 789
I don't know what "xyz" actually is, but I know that:
START=he other
and ... (2 Replies)
Hello ,
I have a script named testscript.sh
wherein I have two variables $var and $final (both of which contain a number)
I have a sed write function inside this script as follows:
sed '1,2 w somefile.txt' fromfile.txt
Now , in the above i want to pass $var and $final instead of... (2 Replies)
I have been searching around the forums here trying to find a solution to my problem but not getting anywhere but closer to baldness.
I have a 20 column pipe "|" seperated text file. The 14th variable doesnt always exist, but will have the format of YYYYMM or YYYY if it does.
I need to take... (2 Replies)
I am trying to pass a regular expression variable from a simple script to sed
to remove entries from a text file
e.g.
a='aaaa bbbb cccc ...|...:'
then executing sed from the script
sed s'/"'$a"'//g <$FILE > $FILE"_"1
my output file is always the same as the input file !!
any... (5 Replies)