LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shell Scripting for KSH (https://www.linuxquestions.org/questions/programming-9/shell-scripting-for-ksh-591254/)

sagarbsa 10-12-2007 04:15 AM

Shell Scripting for KSH
 
Hiii,

I have to add a new blank line to a file before each day field. The file looks some what like this.

Mon 10 oct 11.30 pm
idskafaslkj
dsflhsajkdf
sdflsa,nf
Mon 10 oct 11.55 pm
hfdksaje
dfgsdfg
fdgsd
wrljhfk
werflflakaj
Tue 11 oct 10.05 am
fsadfsf
sdfsadf
asdfsadfa
Wed 12 oct 11.55pm
dfasfasdf
sda
fsdaf
sdf

I have written a shell script but can add space only for a single day ex monday. The command is as follows

sed -e '/Mon/{x;p;x;}' error.log>e.q

How do I add the othwer days? Help me please
Thanks
Sagar

ghostdog74 10-12-2007 05:37 AM

Code:

awk '/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ { print "";}1' "file"


All times are GMT -5. The time now is 02:59 PM.