473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

TEXT file filtering... using shellscripting!!!

Hey,

How i can open a text file using shellscripting,
and new lines?

for example i have the following text file:

-------[test.txt]-------------
Five Moroccans and a Syrian are charged
with 191 murders and 1,755 attempted
murders. A Spaniard is accused of 192
murders and 1,755 attempted murders.
Two of these seven - Jamal Zougam
and Abdelmajid Bouchar - are accused
of actually planting bombs.
----------------------------------

I want to add these lines:

test line 1
test line 2

between "murders. A Spaniard is accused of 192" &
"murders and 1,755 attempted murders." using shellscripting

and the out file will be:

-------[out.txt]-------------
Five Moroccans and a Syrian are charged
with 191 murders and 1,755 attempted
murders. A Spaniard is accused of 192
test line 1
test line 2
murders and 1,755 attempted murders.
Two of these seven - Jamal Zougam
and Abdelmajid Bouchar - are accused
of actually planting bombs.
----------------------------------

thanx alot, sorry for my poor english!!
Feb 15 '07 #1
3 1823
Maybe sed (the stream editor) is what you are looking for?

man sed

should give you food for thought!

hth,
-cybervegan
Feb 15 '07 #2
Motoma
3,237 Expert 2GB
I have posted this link to sed and it's companion tutorial on regular expressions at least 8 times in the past month I have been here.
Feb 16 '07 #3
rm out.txt
sed '4,$d' test.txt >> out.txt
echo "test line 1" >> out.txt
echo "test line 2" >> out.txt
sed -n '5,$p' test.txt >> out.txt
exit

this only works for this question
Feb 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: panic attack | last post by:
Hello everbody, Our system is using Sql Server 2000 on Windows XP / Windows 2000 We have a text file needs to be imported into Sql Server 2000 as a table. But we are facing a problem which is,...
11
by: vivekgrs | last post by:
hi my requirement is read the data from the text file through vb. then calculate the data and write the result on the same text file where the data has retrived thru vb 6.0. how 2 implement...
1
by: sachin10 | last post by:
hi i m sachin, i m new to VB programming.i face some problem regarding the sorting of text file contents using arrays.text file have data in the format as below seq...
2
by: Quentin | last post by:
I am currently working with a text file and cannot seem to get it to filter right. I am trying to delete every line above a keyword "Recipe" and every line below a keyword. Or just move every...
22
by: JJ | last post by:
Whats the best way for me to pull out records from a tab delimited text file? Or rather HOW do I parse the text, knowing that the tabs are field delimiters and a return (I image) signifies a new...
1
by: Paul Lemelle | last post by:
I am trying to read in a text file then use the data in the file. I know how to read a file wiht the System.IO namespace: FileRead fr = new StreamReader("data.txt");...
5
by: Myxamatosis | last post by:
Currently I need to read data from a file, such like this Measurements for Lansing, Michigan during April, 2000 63 32 0.00 54 43 0.10 59 39 0.00 46 24 0.00 52 20 0.00 54 30 0.00
2
by: badwl24 | last post by:
Sir have saved some data in notepad like.... File = F:\Files\SWwork\My Assembly.SLDASM" " Mates" " Coincident1" "" " Coincident1" " Type = 0" " AlignFlag = 1" " ...
1
by: kallem | last post by:
Hi I have one text file generated using SQLServer 2005. While I am importing the text file into one of my PostgreSQL table using "copy" it is giving me the following error: ERROR: invalid...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.