The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
pls help me in scripting lakshmananindia UNIX for Advanced & Expert Users 3 09-04-2007 08:42 PM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 08:12 AM
scripting guru's pls help me with scripting on AIX thatiprashant Shell Programming and Scripting 1 01-20-2006 07:58 PM
New to scripting sdrtaz Shell Programming and Scripting 2 03-18-2005 03:22 AM
HELP! Need HELP scripting! adawg1283 Shell Programming and Scripting 7 09-29-2004 03:48 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-21-2009
ulemsee ulemsee is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 6
Scripting via awk

Hi,
I am trying to understand what is happening here, new to scripting: I have a couple of these, but if I knew what was going on in one I can figure out the rest:

Code:
awk '/rpc-100083/ { $2 = "enable -r" }
$3 ~ /.NOS99dtlogin/ { $t = $2; $2 = $3; $3 = $t }
{ print }' /var/svc/profile/upgrade \
>/var/svc/profile/upgrade.new
mv /var/svc/profile/upgrade.new /var/svc/profile/upgrade

Thanks.

Last edited by vgersh99; 04-21-2009 at 11:13 AM..
  #2 (permalink)  
Old 04-21-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Firstly, please use the BB code tags when posting code/data samples.
Code:
awk '
# if there's a "rpc-100083" pattern found anywhere on a current line, assign a 
# second field ($2) a string "enable -r"
/rpc-100083/ { $2 = "enable -r" }

# if a THRIRD field ($3) contains a pattern ".NOS99dtlogin", then swap the
# values in the SEND and the THIRD fields. Most likely you meant "t" and
# not "$t" variable as a temp place holder.
$3 ~ /.NOS99dtlogin/ { t = $2; $2 = $3; $3 = t }

# print the current record/line
{ print }' /var/svc/profile/upgrade \
>/var/svc/profile/upgrade.new
# Above: output the result to "upgrade.new" file

# move "upgrade.new" to "upgrade"
mv /var/svc/profile/upgrade.new /var/svc/profile/upgrade
  #3 (permalink)  
Old 04-21-2009
ulemsee ulemsee is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 6
Noted.
Ok, Basically , what is being achieved here, e.g how would this help in placing security measures on Solaris?
Sponsored Links
Closed Thread

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 05:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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