LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 03-27-2008, 05:02 AM   #1
jkeertir
Member
 
Registered: Mar 2008
Posts: 75

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,
Keerti
 
Old 03-27-2008, 05:53 AM   #2
Nylex
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 08:38 AM.
 
Old 03-28-2008, 06:17 AM   #3
jkeertir
Member
 
Registered: Mar 2008
Posts: 75

Original Poster
Rep: Reputation: 15
Dear Nylex,

Thanks for the reply,

I could do this by the way you suggested

with Regards,
Keerti
 
Old 03-28-2008, 04:45 PM   #4
prad77
Member
 
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

Gentoo

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


Reply



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-20-2007 11:14 PM
Rewrite rule with query string in the pattern string basahkuyup Linux - Newbie 2 10-17-2006 02:06 AM
finding a dot in a string saavik Programming 2 10-02-2006 09:05 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 01:39 PM
grep - finding string and replacing with new ckibler Linux - Newbie 6 08-01-2003 06:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:53 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
Open Source Consulting | Domain Registration