10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Shell : bash
OS : RHEL 6.8
I have a file like below.
$ cat pattern.txt
hello
txt1
txt2
txt3
some other text
txt4
I want to remove all lines in this file except the ones starting with txt . How can I do this ? (4 Replies)
Discussion started by: omega3
4 Replies
2. UNIX for Advanced & Expert Users
Hi ,
i have a file with data as below.This is same file. But actual file contains to many rows.
i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ?
Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies
3. Shell Programming and Scripting
Here is an example of a file...
foo1,good
foo1,good
foo2,error
foo2,good
Note that both rows for foo1 have good in the 2nd field, but one of the foo2 rows has error...
I need something in ksh/awk/perl that will delete ALL foo2 lines if ANY of them have error in the 2nd field...so:
... (7 Replies)
Discussion started by: dbiggied
7 Replies
4. Shell Programming and Scripting
Hi
I am using the following command to delete a line from the file by line number:
line_number=14
sed "${line_number}d" inputfilename > newfilename
Is there a way to modify this command to specify the range of lines to be deleted, lets say from line 14 till line 5 ?
I tried using the... (5 Replies)
Discussion started by: aoussenko
5 Replies
5. Shell Programming and Scripting
I have a file with ~200K lines, I need to delete 4K lines in it. There is no range.
I do have the line numbers of the lines which I want to be deleted.
I did tried using
> cat del.lines
sed '510d;12d;219d;......;3999d' file
> source del.lines
Word too long.
I even tried... (2 Replies)
Discussion started by: novice_man
2 Replies
6. Shell Programming and Scripting
I have file with 10000 records and i need to delete the lines in single shot based on line number range say from 10 to 51 , 53 to 59 , 105 to 107, 311 to 592 etc... between range works fine for me but how to achive for above case? please help
sed '10,51 {d}' infile > outfile (5 Replies)
Discussion started by: zooby
5 Replies
7. Shell Programming and Scripting
Hello.
My file is like this:
a
b
c
d
e
f
g
h
i
I want to delete all lines after the 3rd line, means after the "c". Is there any way to do this? The lines differ between them and the lines I want to delete does not have a specific word, or the lines I want to keep (a,b,c) does not have a... (4 Replies)
Discussion started by: hakermania
4 Replies
8. Shell Programming and Scripting
Hi,
I have a file will 1000 lines.... I want to deleted some line in the file... like 800-850 lines i want to remove in that...
can somebody help me..?
thanks. (2 Replies)
Discussion started by: Kattoor
2 Replies
9. Shell Programming and Scripting
Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1:
file1
word1... (4 Replies)
Discussion started by: shamushamu
4 Replies
10. UNIX for Dummies Questions & Answers
Hi ,
I have a peculiar case, where my sed command is working on a file which contains lines of small length.
sed "s/XYZ:1/XYZ:3/g" abc.txt > xyz.txt
when abc.txt contains lines of small length(currently around 80 chars) , this sed command is working fine.
when abc.txt contains lines of... (3 Replies)
Discussion started by: thanuman
3 Replies