remove space of each line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove space of each line
# 1  
Old 04-02-2012
Bug remove space of each line

Hi Guys,

I want remove starting space of each line ...

My Input:

Code:
A B C D E
 C V F G H 
 F R T Y U
D F G H J
L  O I U Y G P O 
K O P L O 
 L O I P
 P O P
 P P P P

My Output:

Code:
A B C D E
C V F G H 
F R T Y U
D F G H J
L  O I U Y G P O 
K O P L O 
L O I P
P O P
P P P P

Thanks
# 2  
Old 04-02-2012
Code:
sed 's/^[ \t]*\(.*\)/\1/' infile

This User Gave Thanks to radoulov For This Post:
# 3  
Old 04-03-2012
Code:
sed 's/^ //' file

This User Gave Thanks to SaCai For This Post:
# 4  
Old 04-03-2012
Quote:
Originally Posted by SaCai
Code:
sed 's/^ //' file

... of course Smilie
# 5  
Old 04-03-2012
Try like...
Code:
sed -e "s/^ \{1,\}//" test1.txt>test2.txt

# 6  
Old 04-03-2012
or
Code:
column -t infile

# 7  
Old 04-03-2012
Hi try this one Smilie
Code:
cat input_file|sed 's/^\s*//g' >output_file

cheers,
Senthil
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove after nth space in each line?

Hello, My aim is: * to remove anything after second space including second space itself * or printing the first two fields Concerning the second method, when I run something like while read -r col1, it prints the entire line in each row. Myfile: 11.22.33.44 5566 ns*****.ip-*****.net... (3 Replies)
Discussion started by: baris35
3 Replies

2. UNIX for Dummies Questions & Answers

How to remove fields space and append next line to previous line.?

awk 'BEGIN{FS = "Ç"} NR == 1 {p = $0; next} NF > 1 {print p; p = $0} NF <= 1 {p = (p " " $0)} END {print p}' input.txt > output.txt This is what the input data file looks like with broken lines Code: 29863 Ç890000000 Ç543209911 ÇCHNGOHG Ç000000001 Ç055 ... (4 Replies)
Discussion started by: cumeh1624
4 Replies

3. Shell Programming and Scripting

Remove Space and blank line from file in UNIX shell script

I have below file. I want to remove space at begining of every line and then after also remove blank line from file. I use below code for each operation. sed -e 's/^*//' < check.txt > check1.txt sed '/^\s*$/d' < check1.txt > check2.txt above code not remove all the space... (12 Replies)
Discussion started by: Mohin Jain
12 Replies

4. UNIX for Advanced & Expert Users

Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation? Here is my query: cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}' 02:00:00... (1 Reply)
Discussion started by: bizomb
1 Replies

5. Shell Programming and Scripting

Remove new line character and add space to convert into fixed width file

I have a file with different record length. The file as to be converted into fixed length by appending spaces at the end of record. The length should be calculated based on the record with maximum length in the file. If the length is less than the max length, the spaces should be appended... (4 Replies)
Discussion started by: Amrutha24
4 Replies

6. Shell Programming and Scripting

How to remove tab space and new line from a file using sed?

i am using the default sed package that comes with solaris. (11 Replies)
Discussion started by: chidori
11 Replies

7. Shell Programming and Scripting

Remove line starting from space till end.

Hi, I have a code tag, from which i have the below snippet: intelrpt.GetCMB_FB type=ODBC> intelrpt.GetCMB_FB type=SYBASE> I want the output like: intelrpt.GetCMB_FB intelrpt.GetCMB_FB That is remove the lines starting from WHITESPACE till end. Please help. I am new to... (7 Replies)
Discussion started by: anupdas
7 Replies

8. Shell Programming and Scripting

Remove all words after first space from each line

My file looks like: asd absjdd sdff vczxs wedssx c dasx ccc I need to keep asd sdff wedssx dasx How do I do that experts?:wall::wall: (1 Reply)
Discussion started by: hakermania
1 Replies

9. Shell Programming and Scripting

Stripping out more than a space from a line, but keep single space.

Hi all, Is there a way to perform the above, I am trying to strip out more than one space from a line, but keep the single space. See below output example. My Name is test test2 test3 test4 test5 My Name is test test2 test3 test4 test5 Please note that the lines would contain... (7 Replies)
Discussion started by: eo29
7 Replies
Login or Register to Ask a Question