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
echo(1B) SunOS/BSD Compatibility Package Commands echo(1B)
NAME
echo - echo arguments to standard output
SYNOPSIS
/usr/ucb/echo [-n] [argument]
DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output.
echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi-
ronment variables.
For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows:
o echo your current-working-directory's full pathname
o pipe the output through tr to translate the path's embedded slash-characters into space-characters
o pipe that output through wc -w for a count of the names in your path.
example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w"
See tr(1) and wc(1) for their functionality.
The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if
the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape
characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's
echo() also understands a as the audible bell character; however, these commands do not have an -n option.
OPTIONS
-n Do not add the NEWLINE to the output.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscpu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5)
NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases.
SunOS 5.10 3 Aug 1994 echo(1B)