sed command to delete row


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command to delete row
# 8  
Old 04-08-2008
Now I have problem with sed command.

I try to use sed command with option.
sed -f /tmp/delete EVDO_A12.users
So I can delete previous and next row. But the results only display on the screen. The input file didn't change anything.Which problem ?
# 9  
Old 04-08-2008
Quote:
Originally Posted by anhtt
Now I have problem with sed command.

I try to use sed command with option.
sed -f /tmp/delete EVDO_A12.users
So I can delete previous and next row. But the results only display on the screen. The input file didn't change anything.Which problem ?
I'm sorry? Never heard of redirection? Are you a professional or is this an ordinary homework question?

Regards
# 10  
Old 10-14-2008
Truncating row data BASED ON A PATTERN

HI I HAVE A PROBLEM,MY SOURCE FILE IS OF PATTERN
S1,E-Certified,29,29,2.7,Certified,4,3,2.7,,0,0,0
S2,Certified,4,3,2.7,,0,0,0,,0
S3,E-Certified,29,29,2.7,,0,0,0
S4,,0,0,0,,0,0,0,,0,0,0,,0,0,0

AND THE EXPECTED OUTPUT IS

S1,E-Certified,29,29,2.7
S1,Certified,4,3,2.7
S2,Certified,4,3,2.7
S3,E-Certified,29,29,2.7


THE NUMBER OF FIELDS(NF) IN SOURCE FILE MAY BE MORE THAN 500. WHEREEVER THE FIRST NULL VALUE COMES IT SHOULD TRUNCATE THE ROW.
I TRIED TO SOLVE N WROTE THIS CODE,
awk -F\, '{
if ($2!="") printf$1FS fi;c=0
for(i=2;i<=NF;i++)
{
if ($i=="") i=NF+1 fi;
printf$i ($i!=""?++c%4?i==NF?RS:FSSmiliei<NF?RS$1FS:RS):EXIT);
}
}'
bUT THE OUTPUT COMING IS

S1,E-Certified,29,29,2.7
S1,Certified,4,3,2.7
S1,S2,Certified,4,3,2.7
S2,S3,E-Certified,29,29,2.7
S3,

I AM NOT ABLE TO FIND OUT THE ERROR. IF ANYONE FINDS ANY PROBABLE SOLUTION PLZ SUGGEST ME.

Last edited by pkumar3; 10-14-2008 at 09:34 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete line from file using sed command?

hello Team, I want to delete below linux using sed command but I am getting error.sed -i '/url=/status.cgi?hostgroup=/d' 3 error:sed: -e expression #1, char 32: unknown option to `s' Could you please help me with correct syntax. My line contain / character because of that I am getting... (4 Replies)
Discussion started by: ghpradeep
4 Replies

2. Shell Programming and Scripting

sed command to delete a pattern in a file

Hi Everyone, I have an unusual requirement. Here is where i am stuck for sometime now... I have this text file.. lets say .. output.sql... it has lot of entries... here below is part of the entry... .. . . . . . . . . . . . . . . . .... (3 Replies)
Discussion started by: vivek d r
3 Replies

3. Shell Programming and Scripting

sed command to delete everything after > on line

I have a large data file that I need to edit. There are lines like, > <IDNUMBER> (ST000002) > <SUPPLIER> (ST000002) > <IDNUMBER> (ST000004) > <SUPPLIER> (ST000004) and I need to delete everything after the >, excepting the end of line. > <IDNUMBER> > <SUPPLIER> > <IDNUMBER> > ... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

4. Shell Programming and Scripting

delete the line with a particular string in a file using sed command.

Hello, I want to delete all lines with given string in file1 and the string val is dynamic. Can this be done using sed command. Sample: vars="test twinning yellow" for i in $vars do grep $i file1 if then echo "Do Nothing" else sed `/$i/d` file1 fi done Using the above... (5 Replies)
Discussion started by: PrasadAruna
5 Replies

5. Shell Programming and Scripting

sed command to delete line

HI, Im using the below commmand to delete lines having "(" at the start of a line. sed -e '/^(/d' But i need a command to delete lines that has only "(" in it and no other strings. infile - asdf asdf ( asdf ( asd outfile (1 Reply)
Discussion started by: dvah
1 Replies

6. Shell Programming and Scripting

Delete a line between selected lines using sed or any other command

I want to delete a line between selected lines using sed: e.g. : Between "bus" to "pins", delete lines conaining "signal" word. Input : bus direction signal new signal old pins signal ok end Desired Output: bus direction pins signal end (4 Replies)
Discussion started by: nehashine
4 Replies

7. Shell Programming and Scripting

SED delete only first line command - Help need

Can any one help me how the sed delete only first line command (D) works. sed -f sedcmds File.txt In this how the sed delete only first line command (D) works to delete the blank lines appearing more than ones leaving only one blank and deleting others blanks. While doing step by step when... (2 Replies)
Discussion started by: gwgreen1
2 Replies

8. Shell Programming and Scripting

deleting blank line and row containing certain words in single sed command

Hi Is it possible to do the following in a single command /usr/xpg4/bin/sed -e '/rows selected/d' /aemu/CALLAUTO/callauto.txt > /aemu/CALLAUTO/callautonew.txt /usr/xpg4/bin/sed -e '/^$/d' /aemu/CALLAUTO/callautonew.txt > /aemu/CALLAUTO/callauto_new.txt exit (1 Reply)
Discussion started by: aemunathan
1 Replies

9. Shell Programming and Scripting

sed command to delete points in a certain colum

Dear Unix users, I have a (I think simple) question; I have a file (out.dat) like below, the file contains some line which include 'LOS' string. . LOS 46.5360 91.0220 200708.2515.4900. 5400 64 1100010 . . I would like to delete the points in 4th... (4 Replies)
Discussion started by: mgunduz
4 Replies

10. Shell Programming and Scripting

SED: delete matching row and 4 next rows?

Hi, Tried to look for solution, and found something similar but could not adapt the solution for my needs.. I'm trying to match a pattern (in this case "ProcessType")in a logfile, then delete that line and the 4 following lines. The logfile looks as follows: ProcessType: PROCESS_A... (5 Replies)
Discussion started by: Juha
5 Replies
Login or Register to Ask a Question