I'm extracting mobile features from a file and the structure is this:
I have a list of features also and want to copy the features to another file, so this is my feature list:
and I want the output file to be like this:
as you could see there are some features in the feature list that are not in the input file. so in the output there would be null for that feature.
I used a bash code to just copy the values after the "Feature" word, but as you could see there are features that are not found in the input file and I need a null value for them.
If you are working with a shell script, try the join command. It takes two sorted input files and outputs an SQL like result that joins selected fields from records with matching keys. Take the first file and "roll up" the three line groups to individual lines. Join the second file to this result. Join has options to output non-matched lines as well as matching lines so you can find the "null" results. The key issue can get a little tricky, so I usually construct a key in front of the lines being joined that is extracted/built from the line content.
yes, I think the solution with bash is hard
I think doing it with perl is easier, but i'm not good in perl, do you have any idea how to do it with perl?
Try this...
file1 is the mobile feature
file2 is the feature list
HTH
--ahamed
Thank you so much ahamed, the code worked great, but the thing is i didn't understand the code and how it works
I have some extra line of description between some texts, so your script may not work,
could catch the second line after the match to the output file, or maybe I could delete all of the "Feature" words and the code catch the line after as the output.
could you pleade help me with that?
---------- Post updated at 03:19 PM ---------- Previous update was at 03:16 PM ----------
and there some features in the input that should not be catched
Hi,
I have a problem where i have to hit multiple URL that are stored in a text file (input.txt) and save their output in different text file (output.txt) somewhat like :
cat input.txt
http://192.168.21.20:8080/PPUPS/international?NUmber=917875446856... (3 Replies)
Hi,
I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Hi,
I would like to ask if someone know how to test a files if exist the file is a nfs mount ufsdump archive file..
i used the test operator -f -a h almost all test operator but i failed
file1=ufs_root_image.dump
|| echo "files doesn't exist && exit 1
the false file1 is working but... (0 Replies)
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
Hi Unix Experts,
I like to compile and compare all the features that AIX OS (541L) and Solaris OS (Solaris 10) provide.
If somebody can shed on this topic would be highly appreciated.
Thank you,
Khan (0 Replies)