Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-31-2010, 08:09 AM   #1
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
awk substring command

I configured my ssh for passwordless logins
and grepped out from this config file straight to the command - i used a substring command - but check out tuk100 and cib100 - is there any way i can just display the user, without the server number - with awk?

again i want :

ssh -l tuk tuk100 systemstart
ssh -l cib cib100 systemstart

casper% grep credman ~casper/production/prodfile.t

prodCA cas active 21954 castk100 21954 utility
prodNK cas active 21009 tuk100 21954 utility
prodUS cas active 25624 usstk100 21954 utility
prodFR cas active 23523 usfrk100 21954 utility
prodEU cas active 21461 eustk100 21954 utility
prodDE cas active 21312 destk100 21954 utility
prodIL cas active 25655 cib100 21954 utility

casper% grep credman ~casper/production/prodfile | awk '{print "ssh -l ",
substr($5,1,5), $5 ,"systemstart"}'

ssh -l castk castk100 systemstart
ssh -l tuk10 tuk100 systemstart
ssh -l usstk usstk100 systemstart
ssh -l usfrk usfrk100 systemstart
ssh -l eustk eustk100 systemstart
ssh -l destk destk100 systemstart
ssh -l cib10 cib100 systemstart
Old 07-31-2010, 08:26 AM   #2
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
while read -r line
  case "$line" in
   *credman* ) 
      set -- $line
      echo "ssh -l $user $5 systemstart"
done <"file"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Grep/Awk/Sed to get a substring from a command johnjust Programming 5 01-12-2010 09:02 PM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 05:11 PM
using awk substring function on a file in a bash script matt007 Programming 3 06-17-2008 09:17 PM
get a substring with a bash command xeon123 Linux - General 4 01-26-2007 04:50 AM
php preg_replace substring of a substring senyahnoj Programming 5 12-08-2006 12:31 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:35 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration