![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replace multiple lines between tags using sed | dollylamb | Shell Programming and Scripting | 23 | 06-18-2009 03:44 PM |
| SED - Search and replace lines containing... | pcwiz | Shell Programming and Scripting | 9 | 08-20-2008 06:36 PM |
| replace multiple lines in file | nox | Shell Programming and Scripting | 2 | 08-18-2008 08:44 AM |
| Replace a perticular character of all lines of a file | abovais | Shell Programming and Scripting | 1 | 12-11-2007 05:35 AM |
| how to replace one line in text with several lines | FunnyCats | UNIX for Dummies Questions & Answers | 1 | 01-18-2007 09:52 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I've got a file full of numbers, example:
Code:
cat test.file 60835287 0 51758036 40242437 0 32737144 0 24179513 0 4131489957 Code:
TMP2="/root/test.file"
for number in `cat $TMP2` ;do
calc=$(awk -v a="$number" 'BEGIN{printf "%.2f\n GB", a/1024/1024}')
sed -i 's/$number/$calc/g' $TMP2
done
Code:
TMP2="/root/test.file"
for number in `cat $TMP2` ;do
calc=$(awk -v a="$number" 'BEGIN{printf "%.2f\n GB", a/1024/1024}')
sed -e 's/$number/$calc/g' > test.txt
done
I've also tryd putting the sed command or variables into double quotes (sed -e "s/$number/$calc/g" > test.txt ) but that doesn't help either! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|