Your latest set of revisions to the 1st message in this thread still has grossly inconsistent output. (Some lines have a trailing space; most do not. Some lines have two spaces as field separators; some have one space. The values in the Variables do not always match the corresponding field in your output file.
It looks like MadeInGermany's script captured most of the intent of your latest changes, but missed two points:
You added a new line at the start of the desired output.
Sometimes you want 5 digits after the decimal point in your output and sometimes you want 6.
The script below consistently only uses a single space as the field separator, does not add any trailing space, adds the new line you added as the first line of your output file, and adjusts the output to have the same number of digits after the decimal point as the longest input value for that line:
The output it saves in file2.txt is when your latest sample input is in file1.text is:
Don thanks for your help, but I have some problems with the results of the code.
I have added data to the original question to don`t get wrong answers.
In the real example I have a mix of text data in the file and in some cases have one word, there it`s a problem to the script however in the other cases with more than one word works printing only the variable value, not the operation result.
original data
file 1
Result of the script
Update: I haved modified the original source of your code and I get some differences.
result file
Update 2: I haved update the file1 to replace the space separator inter words with one _ and I get the right value in the output, how I can change the code to accept the space separator between words without limit of words before the number?
Thanks again
---------- Post updated at 03:13 PM ---------- Previous update was at 09:39 AM ----------
Another Problem
Im trying to get the variable value from an assignation of a cat of a file and I cant get the values inside the variable.
In awk -v Variable='value' where value cant load from
I have the variable with the values: example $NUMBERS='20.90000 21.45000 28.25000 29.35000 1.75000 2.75000 8.30000 9.80000 1.61520 1.67080 0.91100 0.89800 103.11000 101.58000 1.35140 1.36840 12.04630 7.73540 2.58430 2.13270 4517.90000 4325.33000 2.73300 2.73300 16097.33000 1225.98000 1225.98000'
If I add $NUMBERS to Variable='$NUMBERS' I get a problem I don`t know why.
If I do echo $NUMBERS I get in STDOUT the correct values.
Thanks in advance
Last edited by faka; 11-29-2013 at 01:14 PM..
Reason: Update
ok, this one is definitely too hard for my shell-script-skills.
Hopefully, there is somebody who can help me with this:
I have a folder with files in it named
0.ppm
10.ppm
2.ppm
...
5.ppm
50.ppm
55.ppm
...
355.ppm
360.ppm
etc.
As you will notice, the order in which the files are... (5 Replies)
Good evening ...
does anyone of you know how to change major/minor numbers of disk devices ?
I had to migrate from raid1 to raid5 and this messed up my ASM cluster - I know which devices should have which IDs to match the content - but I have no idea how to change it.
Any help would be... (2 Replies)
Howdy experts,
We have some ranges of number which belongs to particual group as below.
GroupNo StartRange EndRange
Group0125 935300 935399
Group2006 935400 935476
937430 937459
Group0324 935477 935549
... (6 Replies)
Hello,
Here's a file of mine:
key1:431
key2:159
key3:998
I need to change these keys to something bigger - and I actually need to shift them all by a range of 3.
The output would be:
key1:434
key2:162
key3:1001
I can't find the propper sed/awk line that would alter all my... (4 Replies)
Hi All,
I was using some commands to:
replace a column by a constant string character awk -v a=CA 'NF>1{ $3=a; print; } ' $line>$line"_1"
to copy a column and paste it in another place awk '$5=$2" "$5' $line>$line"_2"
to delete the extra columns awk '{for(i=1;i<=NF;i++)... (9 Replies)
Hi,
i have a flat file namely temp.txt with this data below
ID|name|contact_date
101|Kay|2013-12-26
102|let|2013-12-26
I need to modify the date data in the flat file into MM/DD/YYYY HH24:MI:SS format
let me know the code for this.
Thank you! (5 Replies)
I have a bunch of file numbers in the file 'test':
I'm trying the above command to change all the instances of "H" to "Na+" in the file testsds.pdb at the line numbers indicated in the file 'test'. I've tried the following and various similar alternatives but nothing is working:
cat test |... (3 Replies)
Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do.
I have a file which is formatted as... (4 Replies)
Hi friends,
i need a command which can be used to change the values in file.
I have file which contain some values.
Data_Center_costing=XXXX
Financial_loss=XXXX
operational_cost=XXX
I am not aware about the values of XXXX, They may be 4 digit or less/more than that. but i need these... (12 Replies)