LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2006, 02:45 AM   #1
aravindts
LQ Newbie
 
Registered: Sep 2006
Posts: 5

Rep: Reputation: 0
Post Inserting spaces using SED/AWK ?


Hi All,

I have a requirement to insert two spaces in a file.
The file is of size 350 mb.

The file has 182 characters in each line and i need to insert spaces in positions 174 and 175.The rest of the file content should not be altered .

After inserting the spaces, there should be 184 characters in each line, including spaces.

I am new to unix programming.Please help.

Thanks in advance,
Aravind
 
Old 09-29-2006, 03:07 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
hello aravindts. please try this command.

# cat FILE | sed -i s/"^.\{173\}"/"& "/ > OUTPUTFILE

or to modify directly

# sed -i s/"^.\{173\}"/"& "/ FILE
 
Old 09-29-2006, 04:22 AM   #3
aravindts
LQ Newbie
 
Registered: Sep 2006
Posts: 5

Original Poster
Rep: Reputation: 0
thnx Konsolebox,


i tried your way it says illegal option -i
any other way you know ??
 
Old 09-29-2006, 05:04 AM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
perhaps you're using an old version of sed sorry about my first statement. it should be

# cat FILE | sed s/"^.\{173\}"/"& "/ > OUTPUTFILE
 
Old 09-29-2006, 05:28 AM   #5
aravindts
LQ Newbie
 
Registered: Sep 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Konsolebox,(I would love to know your real name :-) )

This works.

Thank you very much.

Regards,
Aravind
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sed and Awk Gins Programming 7 04-19-2006 10:32 AM
Sed & Awk hinetvenkat Linux - Software 4 05-30-2005 05:10 AM
Problem with SED and blank spaces BigLarry Programming 2 06-10-2004 04:57 AM
awk/sed help pantera Programming 1 05-13-2004 11:59 PM
Inserting a carriage return in awk legtester Linux - General 1 08-17-2003 05:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration