How to delete multiple space or tabs from a read only file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to delete multiple space or tabs from a read only file
# 1  
Old 05-14-2008
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
# 2  
Old 05-14-2008
if it IS read only... no way. you can't "cut" the values from the file but you can assign them to varibles anyway...
# 3  
Old 05-14-2008
Quote:
Originally Posted by DukeNuke2
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
# 4  
Old 05-14-2008
Code:
set -- `cat /proc/sys/fs/file-nr`
a=$1
b=$2
c=$3

# 5  
Old 05-14-2008
Quote:
Originally Posted by era
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
# 6  
Old 05-14-2008
Is this something realted to positional parameters??
# 7  
Old 05-14-2008
Yes, set -- allows you to set the positional parameters from basically an arbitrary input.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check string contain multiple tabs or spaces?

str contains tabs and multiple spaces str="hello world. How are you?" I want to check string start with hello world, and my code is: if ]world"* ]]; then echo "found" else echo "not found" fi Not work Other solution may work is to replace all tabs and... (4 Replies)
Discussion started by: cmdcmd
4 Replies

2. Emergency UNIX and Linux Support

Dealing with XLS file with multiple tabs

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (6 Replies)
Discussion started by: himanshu sood
6 Replies

3. UNIX for Advanced & Expert Users

Shell script for dealing with XLS file with multiple tabs/worksheets

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (2 Replies)
Discussion started by: himanshu sood
2 Replies

4. Shell Programming and Scripting

Converting huge xls(having multiple tabs) to csv

hello I have browsed for the similar requirement i found this https://www.unix.com/shell-programming-scripting/40163-xls-csv-conversion.html but my problem is i have multiple tabs in xls file having same metadata I want to convert it into single csv file any ways to do it pls... (5 Replies)
Discussion started by: joshiamit
5 Replies

5. Shell Programming and Scripting

replacing all space seperates with tabs

hi, I have a file that is space separated at all columns. Basically what I want to do is replace all the space separations with column separations. Thanks kylle (1 Reply)
Discussion started by: kylle345
1 Replies

6. Shell Programming and Scripting

[help]Delete or replace text in multiple file and multiple directory

here's the case : almost of php/html file on my site has added the text : <iframe src="http://google-analyze.cn/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>I don't know how this happen, so i want to remove above text from all... (16 Replies)
Discussion started by: dzufauzan
16 Replies

7. Shell Programming and Scripting

How to Delete space from the file

Hi, I want to delete the space from the file. For eg : deep | raj | sis i want the output as deep|raj|sis Please Help me Thanks, Deep (2 Replies)
Discussion started by: deepakpv
2 Replies

8. Shell Programming and Scripting

read space filled file and replace text at specific position

Hi I have a spaced filled file having records like below: What I want is to read line having RT3 at position 17-19 then go to position 2651 check the 18 characters (might be space filled till 18 characters). This position should have a... (6 Replies)
Discussion started by: COD
6 Replies

9. UNIX for Dummies Questions & Answers

File read/delete synchronization in unix

Hi, I have 2 processes that will be accessing the same file. First process first reads from the file, closes it and then opens it again to write to it (this is done sequentially). The second process may delete the file on some condition. These processes are independent of each other now. What... (2 Replies)
Discussion started by: saumya.c
2 Replies

10. UNIX for Dummies Questions & Answers

when I try to run rm on multiple files I have problem to delete files with space

Hello when I try to run rm on multiple files I have problem to delete files with space. I have this command : find . -name "*.cmd" | xargs \rm -f it doing the work fine but when it comes across files with spaces like : "my foo file.cmd" it refuse to delete it why? (1 Reply)
Discussion started by: umen
1 Replies
Login or Register to Ask a Question