Sponsored Content
Top Forums Shell Programming and Scripting Isolating a specified line - awk grep or somthing else? Post 302324007 by Starcast on Tuesday 9th of June 2009 03:32:16 PM
Old 06-09-2009
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..
 

10 More Discussions You Might Find Interesting

1. SuSE

kazaa or somthing like it?!?!?!?

hey i'm looking for somthing like kazaa that i can use to download some music on, i've relly liked teh progs you guys recommended for MSN so i figured i'd get soem more recomendations....lol thanks. (7 Replies)
Discussion started by: byblyk
7 Replies

2. Shell Programming and Scripting

df -k | grep (somthing)

Hi all, I am getting an hole out put of df -k for df -k | grep / Please let me how can i get for exact one... i want to grep it..! More ever.. Want to know few things...! I am using solaris 9 and want know how to get the CPU utlization from TOP command want calulate CPU utlization... (3 Replies)
Discussion started by: bullz26
3 Replies

3. Shell Programming and Scripting

awk, grep 'df -lah' into one line

Hi Everyone, # df -lah Filesystem Size Used Avail Use% Mounted on /dev/sda7 75G 59G 13G 83% / /proc 0 0 0 - /proc sysfs 0 0 0 - /sys devpts 0 0 0 - /dev/pts /dev/sda5 ... (5 Replies)
Discussion started by: jimmy_y
5 Replies

4. Shell Programming and Scripting

Problems with Sed/awk/grep and line endings

Hello I have created the following script, which is designed to manipulate a text document: #!/bin/sh # Get 3 lines, (last of which is "Quantity"); adjust order; put all three on one line with tabs. FILENAME=~/Desktop/email.txt LIST=$(grep -B2 "Quantity" ${FILENAME} |awk 'BEGIN { FS = "\n"; RS... (6 Replies)
Discussion started by: benwiggy
6 Replies

5. UNIX for Dummies Questions & Answers

Grep /Awk letters X - X in every line and print it as a mac address

hey i m kinda new to this so i will appreciate any help , i have this list of values: pwwn = 0x50012482009cd7a7 nwwn=0x50012482009cd7a6 port_id = 0x280200 pwwn = 0x5001248201bcd7a7 nwwn=0x5001248201bcd7a6 port_id = 0x280300 pwwn = 0x50012482009c51ad nwwn=0x50012482009c51ac port_id =... (4 Replies)
Discussion started by: boaz733
4 Replies

6. Shell Programming and Scripting

AWK-grep from line number to the end of file

Does anyone know how to use awk to act like grep from a particular line number to the end of file? I am using Solaris 10 and I don't have any GNU products installed. Say I want to print all occurrences of red starting at line 3 to the end of file. EXAMPLE FILE: red green red red... (1 Reply)
Discussion started by: thibodc
1 Replies

7. UNIX for Dummies Questions & Answers

Piping grep into awk, read the next line using grep

Hi, I have a number of files containing the information below. """"" Fundallinfo 6.3950 14.9715 14.0482 """"" I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Discussion started by: Paul Moghadam
2 Replies

8. Shell Programming and Scripting

Grep echo awk print all output on one line

Hello, I've been trying to find the answer to this with Google and trying to browse the forums, but I haven't been able to come up with anything. If this has already been answered, please link me to the thread as I can't find it. I've been asked to write a script that pulls a list of our CPE... (51 Replies)
Discussion started by: rwalker
51 Replies

9. Shell Programming and Scripting

awk or sed or grep filter a line and/or between strings

Hi, I have multiple files on a directory with the following content: blahblah blahblah hostname server1 blahblah blahblah ---BEGIN--- aaa bbb ccc ddd ---END--- blahblah blahblah blahblah I would like to filter all the files with awk or sed or something else so I can get below... (6 Replies)
Discussion started by: bayupw
6 Replies

10. Shell Programming and Scripting

sed or awk grep, that will only get the line with more characters.

Is there a command for sed and awk that will only sort the line with more characters? #cat file 123 12345 12 asdgjljhhho bac ss Output: asdgjljhhho #cat file2 11.2 12345.00 21.222 12345678.10 (2 Replies)
Discussion started by: invinzin21
2 Replies
SDL_CDPlayTracks(3)						 SDL API Reference					       SDL_CDPlayTracks(3)

NAME
SDL_CDPlayTracks- Play the given CD track(s) SYNOPSIS
#include "SDL.h" int SDL_CDPlayTracks(SDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes)); DESCRIPTION
SDL_CDPlayTracks plays the given CD starting at track start_track, for ntracks tracks. start_frame is the frame offset, from the beginning of the start_track, at which to start. nframes is the frame offset, from the beginning of the last track (start_track+ntracks), at which to end playing. SDL_CDPlayTracks should only be called after calling SDL_CDStatus to get track information about the CD. Note: Data tracks are ignored. RETURN VALUE
Returns 0, or -1 if there was an error. EXAMPLES
/* assuming cdrom is a previously opened device */ /* Play the entire CD */ if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); /* Play the first track */ if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, 0, 0, 1, 0); /* Play first 15 seconds of the 2nd track */ if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, 1, 0, 0, CD_FPS*15); SEE ALSO
SDL_CDPlay, SDL_CDStatus, SDL_CD SDL
Tue 11 Sep 2001, 22:58 SDL_CDPlayTracks(3)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy