LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-17-2012, 01:55 PM   #1
fortelr0923
LQ Newbie
 
Registered: Jul 2012
Posts: 3

Rep: Reputation: Disabled
insert a "space" on every line in a file at character 27


I would like to change this:

Code:
4506 PH443       WKLMOSFR31OHJKMCT02   ~|123456789
4506 FH3         WKLMOSFRABCHJKMCT02   ~|123456788
to

Code:
4506 PH443       WKLMOSFR31 OHJKMCT02   ~|123456789
4506 FH3         WKLMOSFRAB CHJKMCT02   ~|123456788
using sed or awk.

Thanks for you help!

Last edited by Tinkster; 07-18-2012 at 11:37 PM. Reason: Added code tags for clarity
 
Old 07-18-2012, 11:40 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, welcome to LQ!

Code:
cat fortel 
4506 PH443       WKLMOSFR31OHJKMCT02   ~|123456789
4506 FH3         WKLMOSFRABCHJKMCT02   ~|123456788

sed -r 's/^(.{27})/\1 /' fortel 
4506 PH443       WKLMOSFR31 OHJKMCT02   ~|123456789
4506 FH3         WKLMOSFRAB CHJKMCT02   ~|123456788
If you're happy w/ the visual replace the 'sed -r' with
'sed -ri' to make the change in-file.



Cheers,
Tink
 
2 members found this post helpful.
Old 07-27-2012, 01:00 AM   #3
fortelr0923
LQ Newbie
 
Registered: Jul 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks Tink - that put me back in business!
 
  


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
[SOLVED] Script to insert line into file that contains multiple """ characters tara Programming 2 02-15-2012 07:43 PM
[SOLVED] "Insert" & "Delete" key returns "~" in a terminal. sharky Linux - General 15 04-26-2011 09:36 AM
[SOLVED] while read line and how not to strip character "\" stmas Linux - Software 2 10-19-2010 05:55 PM
bad: Want to insert a line into a text file using "sed" command eliote Linux - General 7 09-19-2010 03:55 AM
SED: how to insert a "&" character in a file carolflb Linux - Newbie 11 12-19-2009 11:48 AM


All times are GMT -5. The time now is 12:48 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration