10-20-2014
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"
8 More Discussions You Might Find Interesting
1. Programming
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
2. Post Here to Contact Site Administrators and Moderators
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
3. UNIX for Dummies Questions & Answers
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
4. Solaris
Hi
Does anyone know what the major and minor numbers are in Solaris? (2 Replies)
Discussion started by: wisdom
2 Replies
5. AIX
Difference between Major and Minor in AIX (5 Replies)
Discussion started by: AIXlearner
5 Replies
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
LEARN ABOUT PHP
datefmt_get_pattern
DATEFMT_GET_PATTERN(3) 1 DATEFMT_GET_PATTERN(3)
IntlDateFormatter::getPattern - Get the pattern used for the IntlDateFormatter
Object oriented style
SYNOPSIS
public string IntlDateFormatter::getPattern (void )
DESCRIPTION
Procedural style
string datefmt_get_pattern (IntlDateFormatter $fmt)
Get pattern used by the formatter.
PARAMETERS
o $fmt
- The formatter resource.
RETURN VALUES
The pattern string being used to format/parse.
EXAMPLES
Example #1
datefmt_get_pattern(3) example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'pattern of the formatter is : ' . datefmt_get_pattern($fmt);
echo 'First Formatted output with pattern is ' . datefmt_format($fmt, 0);
datefmt_set_pattern($fmt,'yyyymmdd hh:mm:ss z');
echo 'Now pattern of the formatter is : ' . datefmt_get_pattern($fmt);
echo 'Second Formatted output with pattern is ' . datefmt_format($fmt, 0);
?>
Example #2
OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'pattern of the formatter is : ' . $fmt->getPattern();
echo 'First Formatted output is ' . $fmt->format(0);
$fmt->setPattern('yyyymmdd hh:mm:ss z');
echo 'Now pattern of the formatter is : ' . $fmt->getPattern();
echo 'Second Formatted output is ' . $fmt->format(0);
?>
The above example will output:
pattern of the formatter is : MM/dd/yyyy
First Formatted output is 12/31/1969
Now pattern of the formatter is : yyyymmdd hh:mm:ss z
Second Formatted output is 19690031 04:00:00 PST
SEE ALSO
datefmt_set_pattern(3), datefmt_create(3).
PHP Documentation Group DATEFMT_GET_PATTERN(3)