Sponsored Content
Full Discussion: Using perl grep and awk
Top Forums Shell Programming and Scripting Using perl grep and awk Post 302293767 by insania on Tuesday 3rd of March 2009 06:05:14 PM
Old 03-03-2009
Using perl grep and awk

I have a script to get server information i wrote in perl because i would like to learn it (and I use it for work). It works great, however i would like to know if there is a good way to reduce the following line.

Quote:
$model = (`dmidecode | grep "Product Name" | awk -F ":" '{print \$2}'`);
Sean
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a file based on pattern in awk, grep, sed or perl

Hi All, Can someone please help me write a script for the following requirement in awk, grep, sed or perl. Buuuu xxx bbb Kmmmm rrr ssss uuuu Kwwww zzzz ccc Roooowwww eeee Bxxxx jjjj dddd Kuuuu eeeee nnnn Rpppp cccc vvvv cccc Rhhhhhhyyyy tttt Lhhhh rrrrrssssss Bffff mmmm iiiii Ktttt... (5 Replies)
Discussion started by: kumarn
5 Replies

2. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

3. Shell Programming and Scripting

grep using Perl

I'm using perl to do a grep of each line in a vendor file and find its occurrences in a specific directory. Any values found is saved in @dir. .....(file opened, etc.) .... while ($line=<FILE>){ @dir = `grep $line * `; } It's the specific usage of the system grep that I'm having... (7 Replies)
Discussion started by: gavineq
7 Replies

4. Shell Programming and Scripting

Perl grep

OK here's the situation: I have got these lines which I have got to parse. If the line contains a particular string and any element from a previously defined array I need to take that particular line and do some further processing. if ((grep(/$_/,$1)) && (grep($pattern,@myarr))) { #Do... (2 Replies)
Discussion started by: King Nothing
2 Replies

5. Shell Programming and Scripting

Read content between xml tags with awk, grep, awk or what ever...

Hello, I trying to extract text that is surrounded by xml-tags. I tried this cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " " which works perfect, if the start-tag and the end-tag are in the same line, e.g.: <tag1>Hello Linux-Users</tag1> ... (5 Replies)
Discussion started by: Sebi0815
5 Replies

6. Shell Programming and Scripting

grep in perl

Hello I want to grep a line from a file saved in some directory. Can anyone please correct the code below: #!/usr/bin/perl -w $file = "/home/output.txt" $grep_line = "closing zip for topic"; `grep $grep_line* $file`; (1 Reply)
Discussion started by: sureshcisco
1 Replies

7. Shell Programming and Scripting

Perl + and Grep

Hi All i have this script that uses glob to look in /var/log/messages.* my @messagefiles = glob "/var/log/messages.*"; and the code that uses it is this grep { /NVRM: Xid/ } @messages) but this spits out this /var/log/messages-20111030:Oct 25 13:43:04 brent kernel: NVRM:... (10 Replies)
Discussion started by: ab52
10 Replies

8. Shell Programming and Scripting

Compare intervals (columns) from two files (awk, grep, Perl?)

Hi dear users, I need to compare numeric columns in two files. These files have the following structure. K.txt (4 columns) A001 chr21 9805831 9846011 A002 chr21 9806202 9846263 A003 chr21 9887188 9988593 A003 chr21 9887188 ... (2 Replies)
Discussion started by: jcvivar
2 Replies

9. Shell Programming and Scripting

AWK/GREP: grep only lines starting with integer

I have an input file 12.4 1.72849432773174e+01 -7.74784188610632e+01 12.5 9.59432114416327e-01 -7.87018212757537e+01 15.6 5.20139995965960e-01 -5.61612429666624e+01 29.3 3.76696387248366e+00 -7.42896194101892e+01 32.1 1.86899877018077e+01 -7.56508762501408e+01 35 6.98857157014640e+00... (2 Replies)
Discussion started by: chrisjorg
2 Replies

10. UNIX for Dummies Questions & Answers

Piping grep into awk, read the next line using grep

Hi, I have a number of files containing the information below. """"" Fundallinfo 6.3950 14.9715 14.0482 """"" I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Discussion started by: Paul Moghadam
2 Replies
EDAC-CTL(8)							EDAC admin utility						       EDAC-CTL(8)

NAME
edac-ctl - EDAC admin utility SYNOPSIS
edac-ctl [OPTION]... DESCRIPTION
The edac-ctl program is a perl(1) script which performs some useful administration tasks for EDAC (Error Detection and Correction) drivers. OPTIONS
--help Display a brief usage message. --mainboard Print mainboard vendor and model for this hardware, if available. The method used by edac-ctl to obtain the mainboard vendor and model information for the current system is described below in the MAINBOARD CONFIGURATION section. --status Print the status of EDAC drivers (loaded or unloaded). --register-labels Register motherboard DIMM labels into EDAC driver sysfs files. This option uses the detected mainboard manufacturer and model num- ber in combination with a "labels database" found in any of the files under /etc/edac/labels.d/* or in the labels.db file at /etc/edac/labels.db. An entry for the current hardware must exist in the labels database for this option to do anything. --print-labels Display the configured labels for the current hardware, as well as the current labels registered with EDAC. --labeldb=DB Specify an alternate location for the labels database. MAINBOARD CONFIGURATION
The edac-ctl script uses the following method to determine the current system's mainboard vendor and model information: 1. If the config file /etc/edac/mainboard exists, then it is parsed by edac-ctl. The mainboard config file has the following simple syn- tax: vendor = <mainboard vendor string> model = <mainboard model string> script = <script to gather mainboard information> Where anything after a '#' character on a line is considered a comment. If the keyword script is specified, then that script or exe- cutable is run by edac-ctl to gather the mainboard vendor and model information. The script should write the resulting information on stdout in the same format as the mainboard config file. 2. If no mainboard config file exists, then edac-ctl will attempt to read DMI information from the sysfs files /sys/class/dmi/id/board_vendor /sys/class/dmi/id/board_name 3. If the sysfs files above do not exist, then edac-ctl will fall back to parsing output of the dmidecode(8) utility. Use of this utility will most often require that edac-ctl be run as root. SEE ALSO
edac(3), edac-util(1) edac-utils-0.18-1 2011-11-09 EDAC-CTL(8)
All times are GMT -4. The time now is 04:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy