Space at beginning of the line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Space at beginning of the line
# 1  
Old 03-17-2012
Space at beginning of the line

How can I delete spaces at the begining of all lines of my file ?
# 2  
Old 03-17-2012
Code:
sed -i "s/^ *//g" inputfile

or
Code:
perl -i -pe 's/^\s+//g' inputfile

There should be lots of threads on this one. Did you try searching the forum?
This User Gave Thanks to balajesuri For This Post:
# 3  
Old 03-17-2012
Quote:
Originally Posted by balajesuri
Code:
sed -i "s/^ *//g" inputfile

or
Code:
perl -i -pe 's/^\s+//g' inputfile

There should be lots of threads on this one. Did you try searching the forum?
Thanks , i did not work at first , but I replaced -i with -u then it woked
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append file name to the beginning of each line

I want to append file names at the beginning of a line for each row file content abc.txt.gz 123|654|987 bcd.txt.gz 876|trf|kjh I want a single output file with below format abc.txt.gz|123|654|987 bcd.txt.gz|876|trf|kjh This one is working but only with unzip files,need to have... (3 Replies)
Discussion started by: rakesh5300
3 Replies

2. Shell Programming and Scripting

beginning less from line #

Hi from a script i want to to read a file beginning at line e.g. number 21 to the EOF. less +n21 temp.txt Bevor the result, it brings an empty page, so that i cant use for scripting. Any idea how the problem can be solved? Thanks in advance! IMPe (2 Replies)
Discussion started by: IMPe
2 Replies

3. Shell Programming and Scripting

comment a line of the patterns is a the beginning of the line

I need to comment the lines starting with pattern "exclude" or "exclude=". If the work exclude comes at any other part, ignore it. Also, ignore, excludes, excluded etc. Ie only comment the line starting with exclude. File contents. exclude exclude= hi I am excluded excludes excludes= ... (9 Replies)
Discussion started by: anil510
9 Replies

4. UNIX for Dummies Questions & Answers

vim copy line and paste at the beginning, middle, and end of another line

How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Discussion started by: cokedude
3 Replies

5. Shell Programming and Scripting

SED - insert space at the beginning of line and multi replace command

hi I am trying to use SED to replace the line matching a pattern using the command sed 'pattern c\ new line ' <file1 >file 2 I got two questions 1. how do I insert a blank space at the beginning of new line? 2. how do I use this command to execute multiple command using the -e... (5 Replies)
Discussion started by: piynik
5 Replies

6. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

7. Solaris

deleting blank space in beginning of line in vi

How can we delete all the blank spaces in the beginning of some lines in a text in vi? Thanks, (2 Replies)
Discussion started by: Pouchie1
2 Replies

8. Shell Programming and Scripting

Remove white space at the beginning of lines

Hi! I store some data obtained with grep or awk in a file. The problem is that some lines have white space at the begining : line1 line2 line3 I use something like grep WORD INFILE >> OUTFILE awk >> OUTFILE I would love if it were possible to remove the white whitout parsing the... (4 Replies)
Discussion started by: tipi
4 Replies

9. UNIX for Advanced & Expert Users

Add new lines with a space in beginning

Hi file1.txt contains GigabitEthernet1/1 GigabitEthernet1/2 GigabitEthernet2/2 GigabitEthernet2/4 GigabitEthernet2/14 GigabitEthernet2/16 can anyone show me how to modify it as below. there is a space at the beginning of the next two lines . ie 'no shut' and 'switch..' !... (8 Replies)
Discussion started by: Aejaz
8 Replies

10. Shell Programming and Scripting

Unix Script with line number at beginning of each line.

Could anybody help me. I need to create a script that reads a text file from STDIN and prints out the file to STDOUT with line numbers at the beginning of each line. Thanks. (5 Replies)
Discussion started by: mascorro
5 Replies
Login or Register to Ask a Question