Hi Friends,
I have the following file and I would like to split it after every line that starts with
done
The file is like this
cat script
#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx
cd /path
#!/bin/bash
while read line
do
c=$(program ${line} | wc -l )
line=${line/:/ }
line=${line/-/ }
echo "${line} ${c}"
done < input > output
#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx
cd /path
#!/bin/bash
while read line
do
c=$(program ${line} | wc -l )
line=${line/:/ }
line=${line/-/ }
echo "${line} ${c}"
done < input1 > output1
After each done, there can be a blank line or an immediate line starting after it. Whatever it is, I would like to split the file based on the done criteria.So, from the above input, I get two output files.
cat script1
#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx
cd /path
#!/bin/bash
while read line
do
c=$(program ${line} | wc -l )
line=${line/:/ }
line=${line/-/ }
echo "${line} ${c}"
done < input > output
cat script2
#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx
cd /path
#!/bin/bash
while read line
do
c=$(program ${line} | wc -l )
line=${line/:/ }
line=${line/-/ }
echo "${line} ${c}"
done < input1 > output1
So, far I tried this
awk '/done/{x="F"++i;next}{print > x;}' script
But, I see an error saying
awk: null file name in print or getline
input record number 1, file om
source line number 1