Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 03-27-2008, 06:02 AM   #1
Registered: Mar 2008
Posts: 70

Rep: Reputation: 15
finding a string

Dear ALL,

I store the output of df command in a file named as /k.
so in /k i have this string

/dev/hdc1 24406832 666000 23740832 3% /mnt/k

now i just want to store "/mnt/k" in a variable of shell script.or in a file.i dont want to use find command.

can anyone help me to do this

With Regards,
Old 03-27-2008, 06:53 AM   #2
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
str="/dev/hdc1 24406832 666000 23740832 3% /mnt/k"
var=`echo $str | awk '{print $6}'`

The result is in the variable $var.

Last edited by Nylex; 03-28-2008 at 09:38 AM.
Old 03-28-2008, 07:17 AM   #3
Registered: Mar 2008
Posts: 70

Original Poster
Rep: Reputation: 15
Dear Nylex,

Thanks for the reply,

I could do this by the way you suggested

with Regards,
Old 03-28-2008, 05:45 PM   #4
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
var=`df | awk '{print $NF}'`

If you want to do it with a file , then

awk '{print $NF}' filename


Last edited by prad77; 04-17-2008 at 04:29 AM.


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
Shell Script: Delete lines til string found or until particular string. bhargav_crd Linux - General 3 12-21-2007 12:14 AM
Rewrite rule with query string in the pattern string basahkuyup Linux - Newbie 2 10-17-2006 03:06 AM
finding a dot in a string saavik Programming 2 10-02-2006 10:05 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 02:39 PM
grep - finding string and replacing with new ckibler Linux - Newbie 6 08-01-2003 07:25 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:30 PM.

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