The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i replace a character with blank space? rollthecoin AIX 8 04-22-2008 05:55 AM
move the last word to begining of next line - SED baskar Shell Programming and Scripting 4 02-15-2008 09:28 AM
append blank space HAA Shell Programming and Scripting 1 09-03-2007 01:43 AM
how to grep for blank records (space,tab,/n)? Browser_ice UNIX for Dummies Questions & Answers 2 08-14-2006 07:47 PM
awk delete blank records xiamin UNIX for Dummies Questions & Answers 1 10-31-2001 02:33 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-07-2008
karthikn7974's Avatar
Supporter
 

Join Date: Jul 2007
Location: Singapore
Posts: 53
delete blank space in begining of line

Hi All,

below is my data file
file.txt
Code:
$$0     ServerA  LAN1    AAA     IT01    04/30/2008  09:16:26
$$0     ServerB  LAN1    AAA     IT02    04/30/2008  09:16:26
here $ is a blank space
how to delete first 2 blank spaces in a file.
Forum Sponsor
  #2  
Old 05-07-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Code:
sed -e 's/^  //' file.txt>file.new
  #3  
Old 05-07-2008
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 796
using Perl:
Code:
perl -pi -e 's/^\s+//' filename
  #4  
Old 05-07-2008
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
Code:
sed -e 's/^  //g' filename > newfile
Thanks
  #5  
Old 05-07-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,314
Quote:
Originally Posted by namishtiwari View Post
Code:
sed -e 's/^  //g' filename > newfile
Thanks

The "-e" and the "g" is redundant, he only wants to delete the first 2 spaces.
The "-e" is for combining multiple commands and the "g" is for global (more) substitutes on a line, this is sufficient:

Code:
sed 's/^  //' filename > newfile
Regards
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0