Sponsored Content
Top Forums Shell Programming and Scripting How to match the first word and print only that line in UNIX? Post 302893352 by web2moha on Tuesday 18th of March 2014 05:52:33 PM
Old 03-18-2014
Linux How to match the first word and print only that line in UNIX?

Below is the file

Code:
DISK-A    109063.2  49  31  40.79
DISK-B    110058.5  49  44  57.07
DISK-c    4402.4    2   1   2.14

from the file, i want to search for 'DISK-A' and print only that line with the first word matching to DISK-A and the output should skip DISK-A.

Desired Output: (If i'm searching for 'DISK-A')
Code:
109063.2  49  31  40.79

Any suggestions would be greatly appreciated.

Last edited by Scrutinizer; 03-18-2014 at 07:20 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search word in a line and print earlier pattern match

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Search for: word1.word2 (Which procedure contain this word, I need procedure name in output. Expected output: procedure test1 procedure test2 procedure test3 procedure test4 ... (7 Replies)
Discussion started by: susau_79
7 Replies

2. Shell Programming and Scripting

Print word 1 in line 1 and word 2 in line 2 if it matches a pattern

i have a file in this pattern MATCH1 word1 IMAGE word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH1 word1 IMAGE word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1... (7 Replies)
Discussion started by: bangaram
7 Replies

3. Shell Programming and Scripting

Print all the words after a match word

Hi, I want to print all words till the last word after the match of "ERROR" word. For e.g. I'll get an sqlplus error with e.g. 1 $ ./calltest_fn.ksh var test_var:=test_fn1; calltest_fn.ksh file1 file2 file3 ERROR at line 4: ORA-06550: line 4, column 11: PLS-00201: identifier... (5 Replies)
Discussion started by: dips_ag
5 Replies

4. Shell Programming and Scripting

print word after pattern match in two instances

i have a file like below. how can i printout the digits followed by the pattern -bwout and -bwin. say i run the script by entering line number 145 (the fourth line), then the o/p should be like 5000000 1024000 8 test1 -ipprot erp -ppsout 500 -ppsin 500 -bwout 300000 -bwin 300000 -statsdevice... (7 Replies)
Discussion started by: sb245
7 Replies

5. Shell Programming and Scripting

Print Line if next line Match a pattern

Hi All, Does anyone know how to print 1H1A....... in peal script print line ^1H1A....... if next line equal 5R0RECEIPT.... Thank for help:D Cat st.txt 1H1A-IN-11-5410-0009420|1010047766|dsds|1|N|IN|IN|000000|1||N|<<<line match 5R0RECEIPT| 5R0RECEIPT|... (2 Replies)
Discussion started by: kittiwas
2 Replies

6. Shell Programming and Scripting

find a word and print n lines before and after the match

how to find a word and print n lines before and after the match until a blank line is encounterd (14 Replies)
Discussion started by: chidori
14 Replies

7. Shell Programming and Scripting

Print a word after a match

Hi all, I have the below line: 08 03 * * 1-5 XXXXXXXXXXXXX -ENVI LDNFOUAT10 -EXE xxxxxxxx -CONFIG \${xxxxx} -SUBCLASS RESET -START -EXTRAAPPARGS \" -env 38LDNFOUAT10 \" >> /tmp/SRRC_xxxxxxx_start.log.`/usr/bin/date +\%Y\%m\%d` 2>&1 I want to print just one word after the string "-env", in... (7 Replies)
Discussion started by: Cvg
7 Replies

8. Shell Programming and Scripting

Print string after the word match

Hi, I have the logs : cat logsx.txt 744906,{"reportingGroups":,"version":"2.0"} 678874,{"reportingGroups":,"version":"2.0"} 193571,{"reportingGroups":,"version":"2.0"} 811537,{"reportingGroups":,"version":"2.0"} 772024,{"reportingGroups":,"version":"2.0"}... (5 Replies)
Discussion started by: justbow
5 Replies

9. Shell Programming and Scripting

Need to print the next word from the same line based on grep string condtion match.

I need to fetch particular string from log file based on grep condition match. Actual requirement is need to print the next word from the same line based on grep string condtion match. File :Java.lanag.xyz......File copied completed : abc.txt Ouput :abc.txt I have used below... (5 Replies)
Discussion started by: siva83
5 Replies

10. Shell Programming and Scripting

Print next line beside preceding line on column match

Hi, I have some data like below: John 254 Chris 254 Matt 123 Abe 123 Raj 487 Moh 487 How can i print it using awk to have: 254 John,Chris 123 Matt,Abe 487 Raj,Moh Thanks. (4 Replies)
Discussion started by: james2009
4 Replies
SADC(8) 							Linux User's Manual							   SADC(8)

NAME
sadc - System activity data collector. SYNOPSIS
/usr/lib/sysstat/sadc [ -C comment ] [ -S { INT | DISK | SNMP | IPV6 | POWER | XDISK | ALL | XALL } ] [ -F ] [ -L ] [ -V ] [ interval [ count ] ] [ outfile ] DESCRIPTION
The sadc command samples system data a specified number of times (count) at a specified interval measured in seconds (interval). It writes in binary format to the specified outfile or to standard output. If outfile is set to -, then sadc uses the standard system activity daily data file, the /var/log/sysstat/sadd file, where the dd parameter indicates the current day. In this case, sadc will overwrite the file if it is from a previous month. By default sadc collects all the data available from the kernel. Exceptions are interrupts and disk data, for which the relevant options must be explicitly passed to sadc (see options below). When the count parameter is not specified, sadc writes its data endlessly. When both interval and count are not specified, and option -C is not used, a dummy record, which is used at system startup to mark the time when the counter restarts from 0, will be written. For exam- ple, one of the system startup script may write the restart mark to the daily data file by the command entry: /usr/lib/sysstat/sadc - The sadc command is intended to be used as a backend to the sar command. Note: The sadc command only reports on local activities. OPTIONS
-C comment When neither the interval nor the count parameters are specified, this option tells sadc to write a dummy record containing the specified comment string. This comment can then be displayed with option -C of sar. -F The creation of outfile will be forced. If the file already exists and has a format unknown to sadc then it will be truncated. This may be useful for daily data files created by an older version of sadc and whose format is no longer compatible with current one. -L sadc will try to get an exclusive lock on the outfile before writing to it or truncating it. Failure to get the lock is fatal, except in the case of trying to write a normal (i.e. not a dummy and not a header) record to an existing file, in which case sadc will try again at the next interval. Usually, the only reason a lock would fail would be if another sadc process were also writing to the file. This can happen when cron is used to launch sadc. If the system is under heavy load, an old sadc might still be run- ning when cron starts a new one. Without locking, this situation can result in a corrupted system activity file. -S { INT | DISK | SNMP | IPV6 | POWER | XDISK | ALL | XALL } Specify which optional activities should be collected by sadc. Some activities are optional to prevent data files from growing too large. The INT keyword indicates that sadc should collect data for system interrupts. The DISK keyword indicates that sadc should collect data for block devices. The SNMP and IPV6 keywords indicate respectively that SNMP and IPv6 statistics should be collected by sadc. The POWER keyword indicates that sadc should collect power management statistics. The ALL keyword is equivalent to speci- fying all the keywords above and therefore all previous activities are collected. The XDISK keyword is an extension to the DISK one and indicates that partition statistics should be collected by sadc in addition to disk statistics. This option works only with kernels 2.6.25 and later. The XALL keyword is equivalent to specifying all the key- words above (including keyword extensions) and therefore all possible activities are collected. Important note: The activities (including optional ones) saved in an existing data file prevail over those selected with option -S. As a consequence, appending data to an existing data file will result in option -S being ignored. -V Print version number then exit. ENVIRONMENT
The sadc command takes into account the following environment variable: S_TIME_DEF_TIME If this variable exists and its value is UTC then sadc will save its data in UTC time. sadc will also use UTC time instead of local time to determine the current daily data file located in the /var/log/sysstat directory. EXAMPLES
/usr/lib/sysstat/sadc 1 10 /tmp/datafile Write 10 records of one second intervals to the /tmp/datafile binary file. /usr/lib/sysstat/sadc -C Backup_Start /tmp/datafile Insert the comment Backup_Start into the file /tmp/datafile. BUGS
The /proc filesystem must be mounted for the sadc command to work. All the statistics are not necessarily available, depending on the kernel version used. sadc assumes that you are using at least a 2.6 kernel. FILES
/var/log/sysstat/sadd Indicate the daily data file, where the dd parameter is a number representing the day of the month. /proc contains various files with system statistics. AUTHOR
Sebastien Godard (sysstat <at> orange.fr) SEE ALSO
sar(1), sa1(8), sa2(8), sadf(1), sysstat(5) http://pagesperso-orange.fr/sebastien.godard/ Linux MAY 2012 SADC(8)
All times are GMT -4. The time now is 08:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy