sed novice bashing away at this....
I am trying to build a sed script that will find the instances of "cn" that have more than one "DirXML" value on them.... see sample below:
I am not having any luck with any variation that tries to find "DirXML.*\nDirXML.*". Isn't there a way to get sed to look at more than one line at a time for a regex value --> sed '/regex/M, /xyz/,/do something' ???
sed '$!N; ....
I guess I just don't know what syntax to use to build the multi-line regex.
Ideally I want the output to be just the cn's that have more than one "Dir" on the liners after them, and just show the cn.... just doesn't seem like it should be so hard.
I didn't even think to use awk - I use awk quite often to extract columns -- never dawned in me to use it to pull rows - never used RS before, but I will now... - Thanks!
Thanks for the perl example as well - will definitely be putting this to use.
[ the first rule of perl club is you do not talk about perl club....]
Isn't there a way to get sed to look at more than one line at a time for a regex value --> sed '/regex/M, /xyz/,/do something' ???
Yes , just everytime there is a change in sed but sometimes use sed can be difficult to others (awk,perl,,,).and and you can use atpresent methods,functions in the others..there are may some difficults especially contain same number or same alpha character line in which method your want (between lines method)
but we write specific sed script for this
however you said sed '/regex/M, /xyz/,/do something' --> sed cant know what value would process for this you must give specific values for example
for exa
the code if "cn: kyu" and "cn: jzaragoza" between lines if contains two DIR lines (for more lines a maybe can a write specific script -> like for 3 lines N;N;N or we find line number between our values and then set a value for this [x=N;N;N;] and then use "$x" instead of values ...... )
or can write with hold buffer
Welcome sed club
*Powerfull Sed*
Hello, everyone. Thanks for taking the time to read my post.
I have nagios config files for which I'm adding the custom variable _mac_address. I have a sed script that places this variable into an existing file. The problem I'm having is if a line in the file is commented out, I don't want the... (2 Replies)
Greetings!
Have a quick question for the community today; this time looking at a nifty little sed puzzle ;)
Consider the following file content to be worked through:What needs to happen is theblock should be removed up to and including the following blank line, leavingI have bits and pieces... (8 Replies)
$ cat bashtest
#!/usr/local/bin/bash
echo <<<"EOF"
line1
line2
line3
EOF
$ ./bashtest
./bashtest: line 3: line1: command not found
./bashtest: line 4: line2: command not found
./bashtest: line 5: line3: command not found
./bashtest: line 6: EOF: command not found
What am i doing... (4 Replies)
Hi,
I have a log file which has sessionids in it, each block in the log starts with a date entry, a block may be a single line or multiple lines. I need to sed (or awk) out the lines/blocks with that start with a date and include the session id.
The files are large at several Gb.
My... (3 Replies)
I am trying to find a line in a file ("Replace_Flag") and replace it with a variable which hold a multi lined file.
myVar=`cat myfile`
sed -e 's/Replace_Flag/'$myVar'/' /pathto/test.file
myfile:
cat
dog
boy
girl
mouse
house
test.file:
football
hockey
Replace_Flag
baseball
... (4 Replies)
I have a file with data records separated by multiple equals signs, as below.
==========
RECORD 1
==========
RECORD 2
DATA LINE
==========
RECORD 3
==========
RECORD 4
DATA LINE
==========
RECORD 5
DATA LINE
==========
I need to filter out all data from this file where the... (2 Replies)
Hi there
As part of a larger script I need to put the output of an ls into a variable which has an incremental number.
ie
nathan@nathan-Vostro-1700:~$ eval 'proc'$val='`ls -ld /proc/9467`'
nathan@nathan-Vostro-1700:~$ echo $proc0
dr-xr-xr-x 8 nathan nathan 0 2012-05-02 09:21... (3 Replies)
hello mighty all
there's a file with lots of comments.. some of them looks like:
=comment
blabla
blablabla
bla
=cut
i'm trying to cut this out completely with this code:
$line=~s/^=.+?=cut//sg;
but no luck
also tryed to change it abit but still I don't understand how the... (9 Replies)
Hi,
I want to write a sed script which from
batiato:
batiato/giubbe:
pip_b.2.txt
pip_b.3.txt
pip_b.3mmm.txt
bennato:
bennato/peterpan:
123.txt
consoli:
pip_a.12.txt
daniele: (2 Replies)