I hope you can help me figure this out. I need to print a record which contains the contents of a config file. The contents of the config file should be found within the 21st and the 30th position of the fixed width reference file.
Config File:
Reference File:
Expected Output:
I hope the gurus can help me
~kokoro
I need to print a record which contains the contents of a config file. The contents of the config file should be found within the 21st and the 30th position of the fixed width reference file.
Config File:
Reference File:
If your reference file always looks like this (that is, the fields are surrounded by ample whitespace AND the search patterns will not appear somewhere else on the line), itkamarajs solution is probably the easiest and fastest.
If the file could contain lines like this:
where it is not possible to match for a word and the search pattern is distinguishable only by the position on the line you will have to do a bit more, for instance a shell loop:
This will "anchor" the pattern to character position 21 in the line by searching for "20 characters followed by $PATTERN".
If the search patterns contain regexp metacharacters (like "*", ".", etc.) you might have to take evn more precautions by escaping these (precede them with a backslash, i.e. "*" -> "\*").
Taking all these precautions will not hurt, even if they are unnecessary, but they might slow down the process, soanalyze your data carefully if they are necessary or not.
I have data coming in the below format for each record
<?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><testdetials>....</test_sox>
<?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox... (8 Replies)
my file input is with tab as delimiter, and in every line, there would be a skip of line with an unexcepted newline breaker. I'd like to remove this \n and put the information in the same line.
INPUT
a1 b1b2 c1
c2 d1
a2 b3 c3 d4
OUTPUT
a1 b1b2 c1c2 ... (9 Replies)
Hi
Input:
{ committed = 782958592; init = 805306368; max = 1051394048; used = 63456712; }
Result:
A map (maybe Associative Array) where I can iterate through the key/value. Something like this:
for key in $map
do
echo key=$key value=$map
done
Sample output from the map:
... (2 Replies)
As i am new to unix so facing some problems in scripting:
here is my question:
i m having two files. 1st file say a.txt contain 3 column like
SPECIALITY|UMP_CODE|SPECIALTY_CODE
Addictive Diseases|25ADD|ADD
Addictive Diseases/Family Practice|25ADD|ADD/FP
Aerospace Medicine|1.041666667|AM... (4 Replies)
Hello all!
I'm trying to put together a small script that will take in a file name and attach a datestamp to the end of it (but before the file type extension).
To illustrate...
Before:
filename.txt
anotherfilename.txt
After:
filename_20090724.txt
anotherfilename_20090724.txt
... (7 Replies)
Hi,
I want to write a script that takes a file and a string as params and adds the string to the middle line of the file. Also, I want to output the results back to the original file passed without using temp files.
I am very much new to UNIX so this is all a little like black magic to me at... (15 Replies)
I am trying to strip out certain characters from a string on both (left & right) sides. For example, line=see@hear|touch, i only want to echo the "hear" part. Well i have tried this approach:
line=see@hear|touch
templine=${line#*@} #removed "see@"
echo ${templine%%\|*} #removed... (4 Replies)
i want to add a string in a very top of a file without using VI or SED or AWK
this is what ive done:
(echo '0a'; echo 'LINE OF TEXT'; echo '.'; echo 'wq') | ed -s myfile
to add astrng right in the middle i could have count the lines of the file and just chenge the address.
... (6 Replies)
Hi,
I have tried many times to add the string into the first line of the file or the middle of the file but could not find the solution.
I first tried by
$echo "paki" >> file
This code only append paki string at the end of file "file" but how can i add this "paki" into the first line or... (5 Replies)