02-15-2011
@Jouuuu
(condition){action}
for lines matching condition, actions are performed
NR>2 | if the record number is more than 2 (that skip the first 2 lines) |
&&/^SCHED / | and the line start by the pattern SCHED<SPACE> |
x=$2" "$5 | put fields 2 and 5 separated by space into the variable x |
/^SCHEDWIN/ | if line start with pattern SCHEDWIN |
x=x" "$2" "$4" "$6" "$8" "$10" "$12" "$14 | concatenate the wanted field into the variable x |
print x" SCHEDPOOL SCHEDRL SCHEDFOE SCHEDSG" | Print x and concatenate the rest of the wanted string |
@Scruti
Yes, i am still an awk noobzor
Last edited by ctsgnb; 02-15-2011 at 01:21 PM..
This User Gave Thanks to ctsgnb For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I want to parse this file....
( 0 , 0 ) =>heading1
( 0 , 1 ) =>value1.1a
( 0 , 2 ) =>value2.1a
( 1 , 0 ) =>heading2
( 1 , 1 ) =>value1.1b
( 1 , 2 ) =>value2.1b
( 2 , 0 ) =>heading3
( 2 , 1 ) =>value1.1c
( 2 , 2 ) =>value2.1c
( 3 , 0 ) =>heading4
( 3 , 1 ) =>value1.1d
( 3 , 2... (15 Replies)
Discussion started by: tungaw2004
15 Replies
2. Shell Programming and Scripting
Hi Guys,
I was wondering if you could help me out -
I have a directory /home/users/datafiles/ which contain files "dat dd-mm-yy.xls"
I am trying to write a script which does the following -
(1) loops through all the files
(2) retrieves the dd-mm-yy string and converts it into a... (12 Replies)
Discussion started by: muser
12 Replies
3. Shell Programming and Scripting
I have a big xml file with little formatting in it. It contains over 600 messages that I need to break each message out in its own separate file.
The xml file looks in the middle of it something like this:
</Title></Msg><Msg><Opener> Hello how
are you?<Title> Some says hello</Title><Body>... (3 Replies)
Discussion started by: quixoticking11
3 Replies
4. Shell Programming and Scripting
#! /usr/local/bin/perl -w
$ip = "$ARGV";
$rw = "$ARGV";
$snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw";
$snmpw = "/usr/local/bin/snmpwalk -Os -c $rw";
$syst=`$snmpg $ip system sysName sysObjectID`;
sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies
5. Shell Programming and Scripting
grep -o '\{1,3\}\.\{1,3\}\.\{1,3\}\.\{1,3\}' then how do i iterate the file names?? (19 Replies)
Discussion started by: ravis83
19 Replies
6. Shell Programming and Scripting
Gurus - Please help with this urgent situation.
I have the following problem to solve using a shell script:
1. There are about 13 files named CONTAINER_1.lst, CONTAINER_2.lst, CONTAINER_3.lst .....CONTAINER_13.lst
2. Each of these files contain about 8 lines (in most cases) containing... (1 Reply)
Discussion started by: inditopgun
1 Replies
7. Shell Programming and Scripting
Hi I need to parse the following data using shell script
Table
-----
stage4n_abc 48
stage4o_abcd 4
adashpg_abc_HeartBeat 1
stage4l_asc 168
Can anyone gimme the solution.
I want each value to get stored in an array or variable and want the value to be greped from another file.... (1 Reply)
Discussion started by: Archana.Dheepan
1 Replies
8. Shell Programming and Scripting
Hi I am new to shell scripting and trying to get values from a text file,
I have a text file with values seperated with "|". like
aga|120220090525|120220090525|120220090525|120220090530
bab|120220090530|120220090530|120220090535|120220090535|120220090535... (4 Replies)
Discussion started by: mannepalli
4 Replies
9. Shell Programming and Scripting
Hey guys,
I have this file generated by me... i want to create some HTML output from it.
The problem is that i am really confused about how do I go about reading the file.
The file is in the following format:
TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies
10. Shell Programming and Scripting
Can some body show me a sed command to remove everyhing upto a '/' and
leave the rest of the line.
cat data.out
This is the directory /tmp/xxx/yy.ksh
I only want to get the fullpath name
/tmp/xxx.yy.ksh
Thanks in advance to all who answer. (3 Replies)
Discussion started by: BeefStu
3 Replies
GREP(1) General Commands Manual GREP(1)
NAME
grep - search a file for a pattern
SYNOPSIS
grep [ option ... ] pattern [ file ... ]
DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as
defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output.
The options are
-c Print only a count of matching lines.
-h Do not print file name tags (headers) with output lines.
-i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre-
tation. Matched lines are printed in their original form.
-l (ell) Print the names of files with selected lines; don't print the lines.
-L Print the names of files with no selected lines; the converse of -l.
-n Mark each printed line with its line number counted in its file.
-s Produce no output, but return status.
-v Reverse: print lines that do not match the pattern.
Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name
argument.)
Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in
single quotes '...'.
SOURCE
/sys/src/cmd/grep.c
SEE ALSO
ed(1), awk(1), sed(1), sam(1), regexp(6)
DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs.
GREP(1)