473,382 Members | 1,238 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,382 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 1822
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.