Remove line starting from space till end.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove line starting from space till end.
# 1  
Old 02-11-2011
Remove line starting from space till end.

Hi,

I have a code tag, from which i have the below snippet:

Code:
intelrpt.GetCMB_FB type=ODBC>
intelrpt.GetCMB_FB type=SYBASE>

I want the output like:

Code:
intelrpt.GetCMB_FB
intelrpt.GetCMB_FB

That is remove the lines starting from WHITESPACE till end.
Please help. I am new to sed.
# 2  
Old 02-11-2011
Code:
sed 's/ .*//' input_file

# 3  
Old 02-11-2011
Code:
awk '{print $1}' "$file"

# 4  
Old 02-11-2011
Thanks for your help, it really works.

Can you please help with the below output:

Code:
imrpt.GetCMB_FB,imrpt.GetCMB_FB,

"," at end of each line.
# 5  
Old 02-11-2011
Code:
sed 's/,$//' input_file

# 6  
Old 02-11-2011
Sorry i am getting same output:

Code:
intelrpt.GetCMB_FB type=ODBC>
intelrpt.GetCMB_FB type=SYBASE>

Thanks in advance.
# 7  
Old 02-11-2011
Code:
awk '{printf $1","}' file

This User Gave Thanks to yinyuemi For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies

2. Shell Programming and Scripting

Cut line from file till the end

Hi I have a 57 line text file and I want to cut first 6 line assigned it to a veriable and again cut next 6 line assigned to same variable till the time file have left 0 line. Please let me know how I can do in scripting. Thanks Sanjay (6 Replies)
Discussion started by: Sanjay2121
6 Replies

3. Shell Programming and Scripting

Remove the spaces at the end of a line starting from a fixed position

I want to remove the trailing spaces at the end of each line starting from a particular position(using ksh script). For example, in the attached file, I want to remove all the spaces starting from the position 430 till the end. The space has to be removed only from the 430th position no matter in... (3 Replies)
Discussion started by: Suryaaravindh
3 Replies

4. Shell Programming and Scripting

Grep from a starting line till the end of the file

Hi Folks, I got to know from this forums on how to grep from a particular line say line 6 awk 'NR==6 {print;exit}' But how do i grep from line 6 till the end of the file or command output. Thanks, (3 Replies)
Discussion started by: Mr. Zer0
3 Replies

5. Shell Programming and Scripting

Need to remove few characters from each line till a pattern is matched

Hi All, I want to remove first few characthers from starting of the line till ',' Comma... which needs to be done for all the lines in the file Eg: File content 1,"1234",emp1,1234 2,"2345",emp2,2345 Expected output is ,"1234",emp1,1234 ,"2345",emp2,2345 How can parse... (4 Replies)
Discussion started by: kiranlalka
4 Replies

6. Shell Programming and Scripting

Subsitute from a position till end of line.

Hi, Having a following file's content, lets say: ABC|ANA|LDJ|||||DKD|||||| AJJ|KKDD||KKDK|||||||||||| KKD||KD|||LLLD||||LLD||||| Problem: Need to replace pipes from 8th occurrence of pipe till end. so the result should be: ABC|ANA|LDJ|||||DKD AJJ|KKDD||KKDK|||| ------- ------- ... (12 Replies)
Discussion started by: _Noprofi
12 Replies

7. Shell Programming and Scripting

Cutting columns starting at the end of each line...

Hi Guys, Can you help me with a sed or a csh script that will have an output from the input below. Cutting the columns starting from the end of the line and not from the start of the line? Sample1 - The underscore character "_" is actually a space...i need to put it as underscore here coz... (2 Replies)
Discussion started by: elmer1503
2 Replies

8. UNIX for Advanced & Expert Users

Urgent Help required : awk/sed help to find pattern and delete till end of line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (1 Reply)
Discussion started by: rajan_san
1 Replies

9. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies

10. Shell Programming and Scripting

Print starting 3rd line until end of the file.

Hi, I want to Print starting 3rd line until end of the file. Pls let me know the command. Thanks in advance. (1 Reply)
Discussion started by: smc3
1 Replies
Login or Register to Ask a Question