The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 2 03-17-2009 01:17 AM
awk script to update header record klut Shell Programming and Scripting 5 04-16-2008 10:04 AM
Reading the header of a tar file(posix header) Tanvirk Linux 2 01-31-2008 08:50 AM
how to include header file in b-sh script bluemoon1 Shell Programming and Scripting 2 09-10-2007 07:45 PM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 08:17 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2009
gates1580 gates1580 is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 1
how to exclude the header in shell script using awk

Hello Everyone
In my shell script, I am retrieving the cluster ID and node number of an LPAR using the following command -

lsclcfg -l

This command's output looks as follows -

CLUSTER_NAME CLUSTER_ID NODE_NR
sch1h004 6104567 3


I want to store only the values of cluster_id and node_nr in the 2nd row into two different variables in my shell script. I don't need the first row i.e. the header.

I was playing around with awk command to see if I can accomplish this but to no avail.
Any thoughts/ideas as to how to accomplish this would be appreciated.
Thanks
gates1580
  #2 (permalink)  
Old 07-16-2009
anchal_khare anchal_khare is online now
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
redirect output to tail


Code:
lsclcfg -l | tail +2

this will show 2nd line onwards.
  #3 (permalink)  
Old 07-16-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,099
assume something like below:

Code:
sed '1d' yourfile | while read line;do
        set $line
        id=$2
        nr=$3
        done
        echo $id"--"$nr

  #4 (permalink)  
Old 07-16-2009
oky oky is offline
Registered User
  
 

Join Date: May 2009
Posts: 20
This might help

cat yourfile | sed '1d' | awk '{ print $2,$3 }'
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0