General :: Why Seq 10 Sed Just Delete Three Lines
Jun 30, 2011
Code:
[root@station3 ~]# seq 10 | sed -e '1,2d' -e '1,2d'
4
5
6
7
8
9
10
We can see that sed just deletes the first three lines. How "seq 10 | sed -e '1,2d' -e '1,2d'"works?
View 1 Replies
ADVERTISEMENT
Jan 26, 2010
I've come across an unusual requirement for a service in my Ubuntu system.Simply put, I need to find a way to search for all instances of a term in a file, delete lines containing containing that term, and delete four lines below each instance of that term. ither that, or copy the entirety of a file to a new file and skip over all lines containing the term plus four below it.This sounds kinda weird, I know. Without going too far into detail, I either have to change the logfile format for a server I'm running which is a huge pain in the butt, or I can just run a script to edit an HTML report generated from said logs. (Said report is really just for managers to peruse, and I like my log format, so I'm pursuing option 2.)
View 4 Replies
View Related
Jun 5, 2011
looking to delete the last 6 lines of a file with sed. figured out how to delete the last line..but i want the last six.
View 6 Replies
View Related
Jul 20, 2010
I have a file that contains 100 ligns, i need to write a script that read 70 lignes and redirect those 70 ligns to another files and these 70ligns have to be erased in the first file
when i write this command
head -70 somefile.txt>test.txt
or
sed -n 70p somefile.txt>test.txt
i have these 70 lines in the text.txt files
but these 70 lines have to be deleted inthe first file somefile.txt
View 1 Replies
View Related
Apr 27, 2010
i've got a file with sorted words - one on each line.How could it be possible to delete thouse lines that have words of length 1 or 2 (1-2 letters). I guess a good way it will be with AWK, n its fuction length(), but getting it, i dont know how to delete those very lines.
View 14 Replies
View Related
Apr 14, 2010
I have to use sed with this problem, and sed is extremely complicated, they could probably teach a whole class on this entire function.
Here's an example to show what I need to do:
Code...
how would I say that every line before I reach the first match of "sweet" should be deleted so that the output will look like: Code...
View 9 Replies
View Related
Jun 17, 2011
How can I delete empty lines in OpenOffice Calc?
View 2 Replies
View Related
Mar 21, 2011
i am having following lines in a file called test.
subscribe parser for dinesh
extend size for dinesh
subscribe parser for anish
unsubscribe parser for dinesh
extend size for arvind
I want to delete all lines which contains the string "dinesh". Is it possible.
View 8 Replies
View Related
Feb 7, 2011
I have a file "test.txt" with following data
#1
aaa
#2
bbb
#3
aaa
#4
ddd
I wanted it to be displayed as
#1
aaa
#2
bbb
#4
ddd
I used awk "'!x[$0]++' test.txt > file.new"
,but it deleted #1 also.I tried using uniq command but i didn't work.
Can anyone Please let me know is there any way to do this using shell script.
View 2 Replies
View Related
May 15, 2011
My problem is like this I have to delete all lines between two pattern match example- suppose below is the content of the file then i have to delete all lines between text1 and text2
...
text1
abc
def
ghi
[Code]....
View 14 Replies
View Related
Dec 21, 2010
I have a bunch of text files, all of them have a .txt extension. They are all located in subfolders of the /MyTextFiles folder (but could be anywhere, no idea what depth). If any line in any of the text files has the word "hello" I want to delete that entire line. I know sed and awk are made for this problem but I can't seem to get the syntax correct.
View 1 Replies
View Related
Jul 28, 2010
I am trying to delete any blank lines within two patterns e.g.
Address: 53 HIGH STREET Cred Id :
MYTOWN
MYCOUNTY
MM12 6MM
Pay Method : Crossed Cheque
The start of my pattern is "Cred Id" and the end is "Pay Method" and I want to delete the blank lines between county and post code. I did find the code below but it doesn't seem to change anything:
sed -ne '/Cred Id/,/Pay Method/!bp' -e '/^$/b' -e -e p ll.out
I can get it to print just the range I'm interested in by doing sed -ne '/Cred Id/,/Pay Method/p'.
View 5 Replies
View Related
Mar 23, 2010
I am trying to edit a print file.
For every occurence of the ^L form feed character I need to remove 5 blank lines after it but still keep the ^L.
I am a rare user of sed and am ok with the basics but am struggling with this.
View 4 Replies
View Related
Jul 7, 2011
I need to chop of the top 30ish lines of several log files until a line starting with "Initialization completed."The trouble is that it's not always the same amount of lines that need to be deleted, and they don't always contain the same information, which is why I would need to delete everything priorhe line starting with "Initialization completed."Right now I have a little script I wrote based on looping each file through several "grep -v" commands with each known pattern of lines I want to ignore, but it is tedious and I have to inspect each file afterwards to make sure nothing is left from above "Initialization completed
View 3 Replies
View Related
Apr 15, 2011
I have a file looks like the following:
digraph topology
{
"192.168.3.254" -> "10.1.1.11"[label="1.000", style=solid];
"192.168.3.254" -> "10.1.1.12"[label="1.000", style=solid];
[code]...
Order of these lines are random... So I cannot delete line #19, for example... And you can see that top four lines I want to delete are pairs. So there might be some clever way to detect the lines, if a line has both "1.9" and "1.11", then delete the line... I am new to perl language. The following is the code I have now... I think I just need to write some code inside the while loop checking if I want to delete the line $dotline before I write to a NEW file.
Code:
#!/usr/bin/perl -w
$TOPPATH = "/tmp";
$NAME = "topology";
$FILENAME = "$TOPPATH/$NAME.dot";
[code]....
View 16 Replies
View Related
Jun 16, 2010
I have a file with three consecutive blank lines. I want to delete two and keep one.Also, if anyone could direct me towards a guide on regular expressions particularly as they apply to sed, I would be grateful. I am having a hell of a time figuring out the syntax.
View 8 Replies
View Related
Jun 24, 2010
I need to find a string in a file ... then delete the line it is on, as well as the next 6 lines. Or, delete the line the string is on and all subsequent lines until the search finds the character "["
example:
filename = test.txt
contents:
[foo]
test>test
test>test
test>test
[Code]....
so, in this example. I'd like to search the file for string 'foo' and delete all lines from that line until [bar] (not deleting the line with [bar])
View 3 Replies
View Related
Sep 16, 2010
I have such a file(test.txt):
abc 123 456
abc 256 145
axd 125 225
[code]...
View 8 Replies
View Related
Mar 10, 2010
i try do modify BASHRC and ENVIRONMENT files on directory ETCthen all the command don't work, such as:SUDO, GEDIT, NAUTILUS, NANO and some others!now i want to edit the 2 files and delete the insert lines
View 9 Replies
View Related
Aug 28, 2010
how to change (rename, delete) lines from boot list in grub 2, Ubuntu 10.04? For example, when I boot my pc, I have a boot list with options "Ubuntu 10.04", "memtest" and "Windows 7". I want to delete "memtest" line, as I don't need it, and rename "Windows 7" line to, for example, "Windows 117". How can I do that? Where I should look and edit? In old grub it was enough to edit /boot/grub/menu.lst, but in Ubuntu 10.04 there is no such file and other grub2-related files (like grub.cfg) do not contain this info to rename or delete lines. So, I can't figure out what to do.
View 3 Replies
View Related
Sep 17, 2009
I am trying to delete lines of a file if they contain text that is present on another file. For example
> cat one.txt:
a
b
c
d
[code]....
I get the following output:
> ./test.sh one.txt two.txt
a
b
d
e
[code]....
View 6 Replies
View Related
Apr 22, 2011
I have been experiencing a problem where the screen loads and after initial first few lines breaks up into multiple repetitions of lines. Reloading helps but has to be repeated when pageing down. Mail is no problem; it is supplied by my network provider. OS is openSUSE 11.2 which I update when advised. Below is a sample from the error console:
[Code]...
View 1 Replies
View Related
May 31, 2011
I've just installed Kubuntu 11.04, switched on wobbly windows effect. It runs very smooth on my Nvidia GeForce 7600 GS with dual screen twinview turned on. However, I get these lines when I drag/move the window upwards - see screenshot:
View 6 Replies
View Related
Nov 24, 2009
How do you remove parts of strings using python? Such as, if I have something like:
Code:
erme1 sdifskenklsd
erme2 sdfjksliel
[code]....
View 3 Replies
View Related
Oct 26, 2009
I have this massive table file with some data in it and I want to replace some lines that are wrong with the correct ones that are in another table file of the same format. The wrong lines are not all together in a block but randomly distributed so I need to make a loop checking if the line is in the other file and if it is, replace it. I want to try and do it with sed or awk but I don't really know how to....
View 12 Replies
View Related
Jul 15, 2011
I have a file with n number of lines where every 2 lines are grouped.
So I want to print the items in a line and the next line in a single line.
For example:
I can print the line and the adjacent together and print the required items like this:
But that's not the order I want. How can I get it printed like below:
View 1 Replies
View Related
Aug 5, 2010
when I run the following command:
awk -F, '{print $10 "," $5 "," $1 "," $3 "," $4 "}' myfile > tmpfile
tmpfile displays the lines but they are all cut off and placed on the line below at the same point.
View 1 Replies
View Related
Mar 5, 2011
I've a big text, and I would like to delete several lines in vim. I was thinking in doing that with marks, but I can't do it. Below it's an example text and I want to delete from <FROM HERE> to <TO HERE>. How can I do that?
[Quote] .....
View 3 Replies
View Related
Jan 19, 2010
I am trying to search for
Code:
<cats>
Sports
</cats>
how do i use the find command to search for <cats>Sports The problem here is that the word Sports is in the next line of <cats> so I cant use -
Code:
find /test/upload/ -type f -name "*.xml" -exec grep -l "<cats>Sports" {} ; -print
How do I put the next line string?
View 8 Replies
View Related
Nov 2, 2010
I have a file with a random word on each line (3k+ lines). How can I get the lines with only five characters? I tried using grep file | more, but it returns all the words (even those less than 5 characters).
Edit: I also tried grep '.{5}' file | more but it doesn't show anything. And grep '.{5}' file | more returns all lines with four or more characters (I'm really confused about why it's doing this).
View 4 Replies
View Related