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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read space filled file and replace text at specific position COD Shell Programming and Scripting 6 04-21-2008 02:40 AM
Need Script to delete multiple entries from a file sidewayz Shell Programming and Scripting 1 02-14-2008 08:38 AM
File read/delete synchronization in unix saumya.c UNIX for Dummies Questions & Answers 2 02-08-2008 10:15 AM
Need to delete multiple lines in a file. kangdom Shell Programming and Scripting 6 10-16-2006 08:02 AM
when I try to run rm on multiple files I have problem to delete files with space umen UNIX for Dummies Questions & Answers 1 09-20-2005 12:20 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: Mar 2008
Posts: 30
Stumble this Post!
How to delete multiple space or tabs from a read only file

Hi,

Actually I am want to cut the three fields of "file-nr" file.

[yogender@gfmdatabase yogender]$ cat /proc/sys/fs/file-nr
638 219 52270


I want to assign these value to diffrent varibales as follow:-
a=638
b=219
c=52270

I tried to use cut command for this purpose and also tried to squeeze all sapces to a single space, but didn't succed.

I know file-nr is a read only file but there would be any way to cut these fields/values.

Kindly help me with this.

Thanks -
Yogender
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-14-2008
DukeNuke2's Avatar
Soulman
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 1,307
Stumble this Post!
if it IS read only... no way. you can't "cut" the values from the file but you can assign them to varibles anyway...
Reply With Quote
  #3 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: Mar 2008
Posts: 30
Stumble this Post!
Quote:
Originally Posted by DukeNuke2 View Post
if it IS read only... no way. you can't "cut" the values from the file but you can assign them to varibles anyway...
Hi DukeNuke,

Could you Please suggest how can i assign these values to three diffrent variables?

Thanks-
Yogi
Reply With Quote
  #4 (permalink)  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Stumble this Post!
Code:
set -- `cat /proc/sys/fs/file-nr`
a=$1
b=$2
c=$3
Reply With Quote
  #5 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: Mar 2008
Posts: 30
Stumble this Post!
Quote:
Originally Posted by era View Post
Code:
set -- `cat /proc/sys/fs/file-nr`
a=$1
b=$2
c=$3
Thanks Era,

I got a good learning. It's working for me.

Regards,
Yogi
Reply With Quote
  #6 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: May 2008
Posts: 1
Stumble this Post!
Is this something realted to positional parameters??
Reply With Quote
  #7 (permalink)  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Stumble this Post!
Yes, set -- allows you to set the positional parameters from basically an arbitrary input.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0