Remove % from a variable

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove % from a variable
# 8  
Old 09-08-2011
Originally Posted by danmero
df -k "$fs" | awk 'NR==2 {print int($4) }'

should do the job Smilie
Yep. Definitely a much nicer solution. But even that one can be shortened a teensy, weensy, little bit more:
df -k "$fs" | awk 'NR==2 {print $4+0 }'


Last edited by alister; 09-08-2011 at 09:50 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove the \r \n from the variable

I a have a delimited file that has a 2 column which I need to read and pull out both columns from the file.Now the while pulling out the second column and storing in a variable I get a \r\n charachter embedded in the output when an od -c is run.How can I remove the \r\n columns from the file. ... (3 Replies)
Discussion started by: Nikhil Gautam
3 Replies

2. UNIX for Dummies Questions & Answers

Remove newline char from variable

I have a file ABC.DAT with 2 columns avaialble Data format : XYZ!$#$!120 XXZ!$#$!1000 YYZ!$#$!104 While running the following code : FILE_COUNTER=1; RECORD_CN_FILE_COUNT=$((`wc -l ABC.DAT| cut -f1 -d' '`)); while do FILE_NAME=`cat ABC.DAT.DAT| head -$FILE_COUNTER |tail -1 | awk -F... (1 Reply)
Discussion started by: Nikhil Gautam
1 Replies

3. Shell Programming and Scripting

Remove appending 0 from file variable

Dear All, i have filename RYK3201_032001002.pdf and i am using below command to get a file file_name1=$(echo $file_name | cut -d "_" -f2 | cut -d "." -f1 | cut -c -6) and then file_name2=${NewFile_NAME}_$file_name1 now the value of file_name1 will be 032001 i want to file_name1... (5 Replies)
Discussion started by: yadavricky
5 Replies

4. Shell Programming and Scripting

How to remove new line from variable?

I have following codes: ~$ var_1="ABC" ~$ echo $var_1 | wc -m 4 ~$ echo -n $var_1 | wc -m 3 ~$ var_2=`echo -n $var_1` ~$ echo $var_2 ABC ~$ echo $var_2 | wc -m 4 ~$ I would suppose the last command ~$ echo $var_2 | wc -m would give 3; but apparently, var_2 still has the new line... (5 Replies)
Discussion started by: littlewenwen
5 Replies

5. Shell Programming and Scripting

PERL : Remove spaces in a variable

I have a variable I want to remove the spaces in between. The output should be How can this be done Any help will be appreciated. Thanks in advance (1 Reply)
Discussion started by: irudayaraj
1 Replies

6. Shell Programming and Scripting

How to remove trailing spaces from a variable?

I am getting a value from a csv file using CUT command, however the command extracting the records with trailing spaces. I am using the result into a sql session to fetch data, because of the trailing spaces the sql session is unable to fetch any data. Please let me know, how to remove this... (2 Replies)
Discussion started by: mady135
2 Replies

7. Shell Programming and Scripting

How to remove the first character on a string in a variable

Hi all, Does anyone know how to code in ksh that will remove the first character in a string variable and replace that variable without the first character? Example: var1=ktest1 will become var1=test1 var2=rtest2 will become var2=test2 Need help please. (10 Replies)
Discussion started by: ryukishin_17
10 Replies

8. UNIX for Dummies Questions & Answers

Remove characters from string variable

I am running a script where one of the variables (the month and year) is input at the command line. What I would like to do is chop off the last few characters of that string to create a new variable, while maintaining the old one. The script is run like this: ./pull_station_v4.csh KYWST... (3 Replies)
Discussion started by: TheSMan5
3 Replies

9. Shell Programming and Scripting

Remove non numeric values from a variable

Hello all, I am working on a basic script but need a little help. Issue: I am running a SQL Query using sqlplus and a shell script. I have the output of the statement stored as variable $A. $A is set to "other text here 45678754 other text here". I need to strip all text except that numeric... (13 Replies)
Discussion started by: ownedthawte
13 Replies

10. Shell Programming and Scripting

Variable has spaces around the string, need to remove them

Hi all, I'm a newbie to the Linux world and I got a couple of shell script questions: (1) How do combine two variables and make it equal to a third variable? For example, I got a variable $A=FirstName, $B=LastName, and I want to combine the variable into one variable so when you echo the final... (4 Replies)
Discussion started by: mikey20
4 Replies
Login or Register to Ask a Question