Minor changes to script


 
Thread Tools Search this Thread
Contact Us Post Here to Contact Site Administrators and Moderators Minor changes to script
# 1  
Old 10-20-2014
Oracle Minor changes to script

isNumeric()
{
numericExpression='^[0-9]+$'
if ! [[ $1 =~ $numericExpression ]]
then
echo 1;
else
echo 0;
fi
}

getColumnData()
{
echo `echo $1|cut -d "," -f1,2 --output-delimiter " "`
}

containsSegment()
{
if [[ $1 =~ "LSNCS808" ]] || [[ $1 =~ "LSNCS097" ]] || [[ $1 =~ "LSNCS148" ]]
then
echo 0;
else
echo 1;
fi
}
FOLDER=/omnicron-space/Lifesys/Segdataconv/csv_files
EXTENSION=csv
SEGMENT_FILE=${FOLDER}/$1_SEGMENT.${EXTENSION}
NON_SEGMENT_FILE=${FOLDER}/$1_NONSEGMENT.${EXTENSION}



# Assuming the first column in the record is always numeric and it is the header of the record
# any line not following the above pattern will be treated as the data belong to the header record
# Skipping the first line in the file
echo " Processing the file $1..."
sed 1q $1 | tee $NON_SEGMENT_FILE >$SEGMENT_FILE
sed 1d $1 |while read line
do
firstCol=(`getColumnData $line`)
isRecordHeader=`isNumeric ${firstCol[0]}`;
if [[ $isRecordHeader =~ "0" ]]
then
if [[ `containsSegment ${firstCol[1]}` =~ "0" ]]
then
#The data has to be appended to the segment file
filetoAppend=$SEGMENT_FILE;
else
#the data has to be appended to the non segment file
filetoAppend=$NON_SEGMENT_FILE;
fi
echo $line >>"$filetoAppend"
else
echo $line >>"$filetoAppend"
fi
done

echo " Finished processing the file $1..."
echo " Generated the following files: $SEGMENT_FILE, $NON_SEGMENT_FILE"


please suggest wat changes to be done in the above script to look for the values in sixth column and search for pattern "VS KSDS"
# 2  
Old 10-20-2014
Please stop making new threads for the same script. Go back to your previous thread.
This User Gave Thanks to neutronscott For This Post:
# 3  
Old 10-20-2014
Moderator's Comments:
Mod Comment Please stop posting technical questions in non-technical forums. Please use CODE tags when showing sample input, output, and code. Please tell us what shell you're using. Please tell us what OS you're using. Please show us a sample of the input you are trying to process. Please show us the output you want your script to produce from that sample input.

This thread is closed.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filtering my major and minor values

I want to remove all rows with a minor repeating count less than 30% compared to the major repeating count from my table. The values of a col(starting col 2) can assume is A,T,G,C and N. Each row has at least 2 values and at most 4 repeating values(out of ATGC). N is considered a missing value... (12 Replies)
Discussion started by: newbie83
12 Replies

2. Shell Programming and Scripting

Minor Calculation Error

Hello everyone!! I got a slight problem doing some calculation from the text file. I able to get the specific data by cutting it using grep and cut. The amount can be calculated but the problem I faced now is even the field which I didnt cut is been calculated too. This is what I meant. The... (2 Replies)
Discussion started by: aLHaNz
2 Replies

3. Shell Programming and Scripting

How to filter out major and minor?

Hi, I have line like this : proj_name/module/trunk/module_1_0 where the first "1" refers to major version and second "0" refers to minor version. any AWK or command like that so that I can filter out the major and minor ? like major= command | input line minor= command |... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

4. AIX

Difference between Major and Minor in AIX

Difference between Major and Minor in AIX (5 Replies)
Discussion started by: AIXlearner
5 Replies

5. Solaris

Help with Major and minor number

Hi Does anyone know what the major and minor numbers are in Solaris? (2 Replies)
Discussion started by: wisdom
2 Replies

6. UNIX for Dummies Questions & Answers

jus a minor issue. please assist if possible.

for an assignment i'm working on i have 2 minor issues with my code for the lines to be displayed after entering a line of code i.e:- $ ls- l foo1.c foo1.c not found $ recycle -rw-r--r-- 1 usr user 31 foo1.c -rw-r--r-- 1 usr user 31 foo2.c this is my working code . ... (1 Reply)
Discussion started by: jerryboy78
1 Replies

7. Post Here to Contact Site Administrators and Moderators

minor issue on question that i had posted !!

to the moderators of this site... i posted a question several weeks ago about a egep -e if you look through my posts you will see that my question was fully plausible as a reasonable post that could have been answered even it was to say that I should search the man pages myself and find the... (4 Replies)
Discussion started by: moxxx68
4 Replies

8. Programming

Device Major/Minor numbers

To further my fledgling knowledge of C, I am re-writing some of the Unix command set. My current command is an ls-style command. All works well, except for device files. How do I get the major/minor numbers for the dev files? I see from the stat struct there are st_rdev and st_dev members. Do... (1 Reply)
Discussion started by: zazzybob
1 Replies
Login or Register to Ask a Question