LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-23-2007, 07:26 AM   #1
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Rep: Reputation: 38
getting gawk to operate on a string in a bash script


I'm just (finally) making my first forays into bash scripting, and the first project i've set myself is essentially a finger clone.

But I'm having trouble with this line:

Code:
uid=$(gawk -F: '{ print $3 }' "$passwd" )
I've no idea how to get gawk to operate on the variable (which is a line grepped out of /etc/passwd). I've tried a few combinations of quote marks, but none want to work.

I've googled a few things, but not found anything useful.

The only way I can get it to work is to write the grep output to an external file, and then get gawk to operate on it.
 
Old 02-23-2007, 10:19 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
ITYM:

Code:
uid=$(echo "$passwd" | gawk -F: '{print $3}')
Hope this helps.
 
Old 02-23-2007, 10:43 AM   #3
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Original Poster
Rep: Reputation: 38
Oh yes! How the hell did I manage not to see that?

*kicks himself*
 
Old 02-26-2007, 01:01 PM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
I've had far more experience in kicking myself than you have, son. (grin)
 
  


Reply


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
Parse String in a Bash script jimwelc Linux - Newbie 8 11-09-2012 08:47 AM
help with bash script: remove * to the last . in string drkstr Linux - Software 3 04-25-2006 05:54 PM
String manipulation with BASH script King V Programming 9 04-21-2006 04:15 PM
looking for string on particular line - bash script tara Linux - General 9 12-14-2005 06:43 PM
Bash Script String Splitting MurrayL Linux - Newbie 1 09-21-2004 04:20 AM


All times are GMT -5. The time now is 02:37 AM.

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