Assuming i have got a file test.dat which has contains as follows:
I would like to traverse through the file, get the 1st occurance of "=" and then need to get the sting contained with in 1st occurance of "=" and 2nd occurance of "=", so that i can validate the string.
Now the same logic has to continue for string contained between 2nd occurance of "=" and 3rd occurance of "=". Could you please let me know if it is possible. Please note that my file may contain any number of "=",so the logic has to be generic. Since I am new to Unix, it would be great if u can guide about the complete code.
Last edited by Scrutinizer; 03-02-2013 at 04:04 PM..
Reason: code tags
Thanks a ton for the reply. Basically i want to have a shell script, which would read the file and do some validations, eg in below example if
if i get string between occurances of "=" , it would be (
). Now since they follow the word Unix=, i want to put a validation so that all these words should have an extension of .sh...similarly for other types...i hope i am clear
Last edited by Scrutinizer; 03-10-2013 at 07:23 AM..
Reason: code tags
Your requirement is inconsistent with your desired output. The first string between occurrences of "=" is
On top of bipinajith's reasonable questions, pls post a consistent request.
Thanks a ton for the reply. Basically i want to have a shell script, which would read the file and do some validations, eg in below example if
Unix = abc def fgt jug
111 2222 3333
Linux = gggg pppp qqq
if i get string between occurances of "=" , it would be (abc def fgt jug
111 2222 3333).
Try this awk script...
Quote:
Originally Posted by rtagarra
Now since they follow the word Unix=, i want to put a validation so that all these words should have an extension of .sh...similarly for other types...i hope i am clear
What exactly do you mean by the above statement...and for validation you would need to initialise an associative array with all known OSes and languages...
Sincere aplogize for delay in response. Your solution is perfectly working fine. But the only issue being it gets me all the details in one go. let me again put my requirement. Below is my sample file:
Now my requirement is to read this file from a shell script, get the words (test1.c test2.c test3.c,test4.c test5.c) and since these files are followed by "C =", i need to check if they have got file extension as ".c".
Similarly next i need to get (perl1.pl perl2.pl) and since these 2 words follow "perl = " i need to check if they have got ".pl" as extension. Similarly for last line C++.
Please note that the data file can have any number of lines.. I hope this time i am clear with requirement.
The solution provided by you getting all the details in one go ie
and really thanks to everyone for their help
Last edited by Scrutinizer; 03-10-2013 at 07:04 AM..
Reason: code tags
Hi....I need one help....
I'm having a files which is having the data as follows...
a
b
c c
d d d
e
f
Now I need to find out distinct characters from this file and the output should be as follows -
a
b
c
d
e
f
Can you please help me on this? I'm using KSH script. (18 Replies)
Hi all.
I have a .txt file that I need to sort it
My file is like:
1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO)
2- ... (10 Replies)
Hi,
We have a file (e.g. a .csv file, but could be any other format), with 2 columns: the old value and the new value. We need to modify all the files within the current directory (including subdirectories), so find and replace the contents found in the first column within the file, with the... (9 Replies)
After spending sometime playing around with my script I just cannot get it to do what I want. So I decided to ask. My file looks something like this:
I am using the following code to extract sequences that contain dashes
awk '/^>/{id=$0;next}{if (match($1,"-")) print id "\n" $0}' infile
... (17 Replies)
Hi, I have a series of files (upwards of 500) the filename format is as follows
CC10-1234P1999.WGS84.p190
each of this files is in a directory named for the file but excluding the extension.
Now the last three numeric characters, in this case 999, can be anything from 001 to 999, I need to... (3 Replies)
I have a DNA file like below and I am able to write a short program which finds/not an input motif, but I dont understand how I can include in the code to report which position the motif was found. Example I want to find the first or all "GAT" motifs and want the program to report which position... (12 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)
Hi I made a post earlier but now my problem has become a lot more complicated.
So I have a file that looks like this:
Name 1 13 94 1 AGGTT
Name 1 31 44 1 TTCCG
Name 1 13 94 2 AAAAATTTT
Name 1 41 47 2 GGGGGGGGGGG So the file is tab delimited and what I want to do is find... (8 Replies)
Hello all
I am getting data like
col1 | col2 | col3
asdafa | asdfasfa | asf*&^sgê
345./ |sdfasd23425^%^&^ | sdfsa23
êsfsfd | sf(* | sdfsasf
My requirement is like
I have to to read the file and remove all special characters and hex characters ranging form 00-1f from 1st column, remove %"'... (1 Reply)