Thanks PHV for the solution. The s! was giving me some problem so I modified it and added \s to remove the spaces before aaa.
tr ';\n' '\n;' <FILE | sed '/^;*\s*aaa /s/ ccc ddd$' | tr '\n;' ';\n'
Hi PHV,
No, I don't want any other lines that begins with non-"aaa" to change.
For example:
basas sdsa asda ccc ddd;
should not change.
Just to simplify my test case:
aaa 111 222 ccc ddd;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs ccc ddd;
basas sdsa asda ccc...
Hi,
I would like to search between "aaa" and ";" for "ccc ddd" and replace it with a blank. To me, each "line" of interest begins with "aaa" and ends with a semicolon ";".
For example,
aaa 111 222 ccc ddd;
sdfs fdd ccc ddd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc ccc ddd;
aaa ddd ccc ccc...
Sorry for the confusion. I had a typo in my example. No, not remove the last 2 fields of every line that ends with a semicolon.
I want to search between "aaa" and ";" for "ccc ddd" and replace it with blank. I corrected and here's another test case:
aaa 111 222 ccc ddd;
sdfs fdd ccc ddd...
Well, I just figured out how to do it with sed.
sed '/aaa/s/ ccc ccc;/;/g' FILE
but i have a more complicated case like this:
aaa bbb
222 333 444
eee ccc ddd;
eee ccc ddd;
I want it to be:
aaa bbb
222 333 444
eee;
eee ccc ddd;
which means a line always end with a semicolon ";"...
Hi,
I have a file looks like this:
aaa bbb ccc ddd;
123 321 423 444;
aaa eee ccc ddd;
aaa fff ccc ddd;
12243455465467;
I want the output to look like this:
aaa bbb;
123 321 423 444;
aaa eee;
aaa fff;
12243455465467;
Basically, just remove the last 2 entries of the lines begin with "aaa" but...
Hi,
I have a file that looks like this:
textxxxxxx abc 100 200
text again.....300 100
more text......
(5853.2775,2960.825)
(5853.275, 2960.82) (5853.28, 2960.83)
(6185.3225,6330.975)
(6185.32, 6330.97) (6185.325, 6330.98)
I would like to add 10 to the numbers of...
Hi,
I have a file that looks like this:
line1 - This is line #1
line1 - This is line #1
11 11 11
500 600
600 700
700 800
line7 - This is line #7
line8 - This is line #8
I would like to subtract 10 ONLY from the lines with 2 numerical columns. Meaning it should look like this:
line1 - This is...
Thank again for the solution and detail explanation. Perhaps the previous testcase isn't a good one. Here's what I really want.
=== Input file ===
123 45676 677
par123.123
sfsf sf dsfsd sfd s
wefrewr23 23432 53 65 5
dgasgd.4354ssd
sdfs{#$%$#%$%!!!@ et g trhrt
werd wewete 24356
655b56 fg d...
Actually, I am intending to filter out those Parxxx with line length > 1.
set length [llength $line]
if {$length==1} {
set result [regexp {(^Par\d+)} $line match fname]
if {$result==1} {
#open output_file
#set file_opened to 1
...
...
..
so if the paragraph starts with "Par123 sas...
By the way, assuming some of the lines ($line) consist of special characters like "} % #..", what can be done to ignore those special characters in $line?
Hi,
I have a file that looks like this:
Par1
sdfsdff c 568768
dfdfdfdty6v 655
dfdsdfd 1243
END1abcd
Par2
tyrtyrfghgfh
rtytrfg gffg
gfhjkk dffg
END2abcd
I would like to write a TCL script to split what's between Par and END into seperate files. For example,
::File Par1.txt::
Par1
sdfsdff c...
Hi guys,
I would like to print the line before and the line after "JohnDoe" is found. For example,
===Input text file===
line1
line2
JohnDoe blah blah blah
line4
line5
===Desired output file===
line2
line4
Can someone suggest a good way of doing this?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.