It is no surprise that my script doesn't work with your new data. This is a completely different problem from what you posted in your original message in this thread (in fact from any of the 12 different versions of that message). In your original problem, any line with three or more "words" on the line had a number as the last word and that word was to be modified by the list you supplied in the variable named Variable. So my script copied lines with less than three words to the output without changing them and made the change you requested to the last word on all lines with three or more words.
The fact that you have also changed your last message six times is also a bit disconcerting.
You say that the script isn't working with your new data, but you haven't shown us what output you want. You have 27 values in Variable and you have 30 lines in your sample input file that have a last word that is entirely numeric. How is the script supposed to determine which lines are to be modified? If you can tell me how to recognize lines that need to be modified, it can be made to handle any character you want as a field separator. But you have to CLEARLY describe your input file format and your output file format.
Note also that your 1st set of requirements had all replacement values with 5 digits after the decimal point and you wanted 5 digits to be printed after the decimal point for the values that were calculated and did not add any lines to your output file. Your 2nd set of requirements had some replacement values with 5 digits and some with 6 and you wanted the calculated value to be printed with the same number of digits after the decimal points as were in the replacement value for that line and requested that the line:
be added as the first line to appear in the output file.
Now it looks like you're back to only having 5 digits after the decimal point. Can the script assume that all computed values should be printed with 5 digits, or should it determine the number of digits to be printed based on the number of digits being used in each number involved in the calculation on that line?
Do you want any lines to be added to your output file? If so, what should they be?
When you have a variable that is to be expanded by the shell, it needs to be inside double quotes; not single quotes. I.e.:
not:
But, it would be more efficient to just let awk read the contents of your list of replacement values from the file that you are using to set the variable. What is the name of the file that you are using to initialize the value of $NUMBERS? Inside that file, is each value on a separate line, or are there multiple values on input lines? If there are multiple values on lines, what is the separator between values?
In the future, if you want our help, please post sample input that is representative of the input you want to process, clearly state the algorithm to be used to convert your input to the output you want, and provide sample output that EXACTLY corresponds to the sample input and the algorithm you specify. Constantly changing requirements wastes our time and your time.
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)