![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 how to delete first 2 blank spaces in a file. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
sed -e 's/^ //' file.txt>file.new |
|
#3
|
||||
|
||||
|
using Perl:
Code:
perl -pi -e 's/^\s+//' filename |
|
#4
|
|||
|
|||
|
Code:
sed -e 's/^ //g' filename > newfile |
|
#5
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |