sorry I messed up the last post with too many mistakes and corrections so I closed it and opening a new one which should be clear to everyone .my apologies to the admins.
I am using sun solaris and Linux , what I want is SED to print any string (or output it to a file preferably) that does not have either "01","03","05","07","10" or "11" on the 9th and 10th position .
e.g from the file below I only want these three lines
hope I am clear this time.
thanks
Moderator's Comments:
edit by bakunin: we have no problems at all with messed-up posts, but we do take issue with missing CODE-tags. I'd appreciate it if i don't have to edit them in for you in the future because you use them yourself.
I am using sun solaris and Linux , what I want is SED to print any string (or output it to a file preferably) that does not have either "01","03","05","07","10" or "11" on the 9th and 10th position
This is done with a simple rule. sed will per default print every line in the input file, so we just have to "delete" the lines we are not interested in.
Notice that this does not address the lines with "10" and "11". We will get to this but first let us have a look at the regular expression:
It says: "^" is the beginning of line, so the beginning of line, followed by 8 characters ("." is "any character), followed by a "0". This is followed by a character class: "[1357]" means any one (but only one) character of the mentioned set. So in fact it is a convenient way of saying either "01" or "03" or "05" or "07".
The following list of commands - in this case only one command, the "d" - is executed and so these lines do not get printed, all others do.
We have left out two more types of lines you also wanted to exclude: "10" and "11" in 9th-10th position. It would be possible to put that all into one complex regex, but it is far easier (and, in my humble opinion, easier to read) to simply have two rules instead of one. Therefore:
Which should do what you want. Notice that sed does not change your input file so deleting lines only affects the output, not your source. If you want to lastingly change your inut you have to do it in two steps: let sed write to a different output file, then overwrite the source with this:
@bakunin: I'm afraid the -n option suppresses ANY printout regardless of lines being deleted (by the regexes found) or not. With the -n removed the solutions is close to the ones proposed in the requestor's other thread. Please continue discussions over there. This duplicate thread is closed.
Hi
I am trying to parse a grep output using awk. It works fine individually and not working under the loop with variable name assigned.
cat > file.txt
dict=/dictr/abcd/d1/wq:/dictr/abcd/d2/wq:/dictr/abcd/d3/wq:
sample tried code
Nos=`grep -w "dict" file.txt | awk -F"=" '{print... (10 Replies)
Hello All,
I am trying to parse a log file and i got this code from one of the good forum colleagues, However i realised later there is a problem with this awk script, being naive to awk world wanted to see if you guys can help me out.
AWK script:
awk '$1 ~ "^WRITER_" {p=1;next}... (18 Replies)
All,
Can somebody provide me with some sed expertise on how to parse the
following line.
27-MAR-2011 10:28:01 * (CONNECT_DATA=(SID=dmart)(CID=(PROGRAM=sqlplus)(HOST=mtasnprod1)(USER=mtasnord))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.197.7.47)(PORT=54881)) * establish * dmart * 0
I would like... (3 Replies)
Hello
I want to convert my cron list into a csv
Can you please help me with sed ?
eg:
Convert
#06,21,36,51 * * 1,2 * (. ~/.profile ; timex /some/path/script -30 -15) >> /some/path/logfile2 2>&1
* * * * * (. ~/.profile ; timex /some/path/script2) > /some/path/logfile2
To:... (1 Reply)
Scripting geeks please advice how this script should parse the input parameter to File Name convention to search the strings. Enclosed is the basic view of the search architecture.
##*******************************************************************************************************
## ... (2 Replies)
I am using MKS tool kit on windows server. One config variable is defined in windows environment and I am trying to use that variable.
# Below RootDir is defined in windows
RootDir="\\f01\var"
# in unix script
details="$RootDir/src|$RootDir/tgt"
src=`echo $details|awk -F '|' '{print... (1 Reply)
Hello,
We have edi files we need to do some extra parsing on.
There is a line that shows up that looks like this:
GE|8,845|000000000
We need to parse the file, find the line ( that begins with GE "^GE" ), and remove the comma(s).
What is the easiest way to do that ? I know I can grab... (5 Replies)
--------------------------------------------------------------------------------
Hi All,
I am reading some logfiles and parsing data and printing to some textfile.
Here is my code
OLDIFS=$IFS
IFS='
' # just a newline, in single quotes
while read data
do
if
then
#Parsing the... (4 Replies)
hi , i would like to parse some file with the fallowing data :
data data data "unwanted data" data data "unwanted data"
data data data data #unwanted data.
what i want it to have any coments between "" and after # to be erased using awk or/and sed.
has anyone an idea?
thanks. (3 Replies)