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
Isolating the Month in Perl popeye Shell Programming and Scripting 4 02-06-2009 06:47 PM
cat file1 read line-per-line then grep -A 15 lines down in fileb irongeekio Shell Programming and Scripting 6 01-28-2009 06:30 AM
Grep or other ways to output line above and/or below searched line sammac UNIX for Dummies Questions & Answers 2 07-24-2008 03:28 AM
df -k | grep (somthing) bullz26 Shell Programming and Scripting 3 03-04-2008 02:26 PM
kazaa or somthing like it?!?!?!? byblyk SuSE 7 05-21-2004 03:33 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-09-2009
Starcast Starcast is offline
Registered User
  
 

Join Date: Jan 2009
Location: Minneapolis, MN
Posts: 13
Isolating a specified line - awk grep or somthing else?

I'm trying to isolate attached hard drives that auto-mount to /media so that I can use them as variables in a bash script...

so far I'm here:


Code:
variable=$(ls /media | grep -v cdrom )

This lists all the connected drives, each on it's own line and doesn't list anything I don't want (cdrom folders)... is there a way using grep or awk to take the output of my "grep -v cdrom" and print a specific line...

I'll only ever have 6 drives connected at time, so I figure I'd just use the code 6 times to get each drive and keep it simple... Obviously the below script doesn't work but, something like this...


Code:
drive1=$(ls /media | grep -v cdrom | awk line1 )
drive2=$(ls /media | grep -v cdrom | awk line2 )
drive3=$(ls /media | grep -v cdrom | awk line3 )
drive4=$(ls /media | grep -v cdrom | awk line4 )
drive5=$(ls /media | grep -v cdrom | awk line5 )
drive6=$(ls /media | grep -v cdrom | awk line6 )

I did quite a bit of searching for this, but I must not using the correct terminology, because I couldn't find anything?

Thanks for any help!
-Starcast

Last edited by Starcast; 06-09-2009 at 04:47 PM..
 

Bookmarks

Tags
grep or

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 09:23 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