Hi,
I have a several files with ".out" extension in a folder and each file has the below like contents
....
appname: wonder1
.....
logname78.log
logname88.log
.....
CAP: 2
.....
appname: wonder54
......
logname28.log
logname58.log
logname54.log
.....
CAP: 3
.....
appname: wonder11
.....
logname92.log
.....
CAP: 1
.....
Where "...." can be bla bla bla any string.
Below is the desired output
wonder1
wonder54
wonder11
logname78.log
logname88.log
logname28.log
logname58.log
logname54.log
logname92.log
I run a for loop to traverse through the folder picking one file at a time.
for file in *.out
do
for csfile in $(grep -F 'appname' $file | awk '{print $2}')
do
echo $csfile
for counter in $(grep -F 'CAP:' $file | awk '{print $2}')
do
let start=1
for i in {$start..$counter}
do
echo " "
done
done
done
for logg in $(grep -F '.log' $file)
do
echo $logg
done
echo " "
done
The above effort does not yield what i desire ...
Problem 1: The value of CAP remains always the same i.e the first vaue in the file.
Problem 2: The .log files are not seperated by blank lines as seen in the desired output.
Current output looks something like this
wonder1
wonder54
wonder11
logname78.log
logname88.log
logname28.log
logname58.log
logname54.log
logname92.log
I know the basics of loops but can u help me structure my code get the correct output.