I have:
A list of parameters that repeat (in .txt file)
Example: params.txt
Series: XYZ
Manufacturer: ...
Software Version: ...
Year made: ...
Series Series: XYZ
Manufacturer: ...
Software Version: ...
Year made: ...
Series Series: ABC
Manufacturer: ...
Software Version: ...
Year made: ...
Series Series: ABC
Manufacturer: ...
Software Version: ...
Year made: ...
Since this list is pulled from a different file, the Series XYZ or ABC, etc repeat several times along with their Manufacturer, Software version parameters (if the series is name is same, then so will be the parameters for that series).
What I need to do:
I need to make a different file pulling information from params.txt
This file will contain only ONE instance of each series along with series specific parameters. Any repetition should not be copied.
Any suggestions on how to do that will be appreciated!
homework?
awk pattern range will do here.
==>> Read lines betwwen patterns "Series:" and "Year made:"
==>> If 1st field($1) is "Series:", store Series value ($2) in a array i.e. a[$2]++
==>> Print lines if current Series value in array is equal to 1
homework?
awk pattern range will do here.
==>> Read lines betwwen patterns "Series:" and "Year made:"
==>> If 1st field($1) is "Series:", store Series value ($2) in a array i.e. a[$2]++
==>> Print lines if current Series value in array is equal to 1
I have finished school long ago, so no, it's not homework
I am cataloguing differences between scanning parameters.
I am not particularly familiar with awk (or with c-shell) at this point but I have gotten the script to give me a lengthy file with all the information I need. Now I am just this one step away from having a nice descriptor file without any duplicates in it.
We are not supposed to give direct answers to homework kind of questions so we used to check that atleast for newcomers. So Nevermind on asking if it was homework.
I hope following will give you unique records:
If output is not as expected, pls post the expected one.
Last edited by anurag.singh; 01-07-2011 at 11:39 AM..
We are not supposed to give direct answers to homework kind of questions so we used to check that atleast for newcomes. So Nevermind on asking if it was homework.
I hope following will give you unique records:
If output is not as expected, pls post the expected one.
Thank you, anurag.singh, it works perfectly. However, for each Series it only outputs Year Made, while I need it to out put 10 other parameters (for each unique series). Therefore what I get now is correct, but incomplete:
From the input given by you in post #1, I suppose output will be:
Only one set of info to be displayed for a given "Series:"
Looks like for the set, starting pattern is: SeriesDescription
and ending pattern is not clear in your above post. Pls replace "Year made:" with the ending pattern and try.
If no good, then please post exact input format and expected output for that again.
We need to know the exact start and stop pattern for a set of data.
Last edited by anurag.singh; 01-07-2011 at 12:05 PM..
This User Gave Thanks to anurag.singh For This Post:
Dear All,
I have script.
Dest=""
IFS='
'
for translation in $(echo $MY_MAP)
do
t1=$(echo $translation | cut -d"=" -f1)
t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1)
if
then
Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2
break;
... (4 Replies)
Dear Friends,
I am trying to get a script in c-shell working but no way! I don't know why but on my mac was working and now on linux is not!
Basically the script should accept a root_file_name and work in batch on files. This is the script:
#!/bin/csh -fn
setenv IMAGIC_BATCH 1
... (3 Replies)
Hello, I'm trying to write a script which is listing files based on different preferences, like filetype or permissions. All is fine, except for one: I want to list files in /home which has a different owner than the home directory it is in.
Here is an example:
/home/UserA is the directory, and... (10 Replies)
File_A contains Strings:
a
b
c
d
File_B contains Strings:
a
c
z
Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below.
Resultant... (7 Replies)
Hi, I need a script that will:
1. Go through about 20 different folders, each containing about 20 1d files. The 1d files go something like this:
22.253 37.707 78.117 112.374 127.944 156.067 180.956 233.785 249.256 ... (1 Reply)
Hi,
I'm using FreeBSD 6. I want to know which Shell I'm using. So I gave the command:
-sh-3.1$ ps -p $$
PID TTY TIME CMD
15547 pts/1 00:00:00 sh
Which shell is "sh"? Is it C Shell or Bourne Shell or Korn Shell?
Also, are Bourne & Korn shell one and the same or are... (4 Replies)
Hello all,
Any idea how to check whether a variable holding null value or not. if -z option works fine in bash, where as it is not working in sh.
bash-3.00$ sh
$ TEST=
$ if ; then
> echo "Null"
> else
> echo "Not null"
> fi
sh: test: 0403-004 Specify a parameter with this command.... (2 Replies)
Below is a description of what im trying to achieve:
Write a shell script to concatenate lists together, and output the resulting list. Do not include any argument that is a sub-list of the entire list. (The script will clean the list of any redundant items.) You must preserve the original order... (1 Reply)
Hi all,
Can anyone provide me any checklists or a list of steps I should follow before executing my scripts.
Could also tell me if there are any other standards to be followed while shell programming like naming conventions for variables etc.
Your help would be much appreciated.
Regards,... (2 Replies)