Sponsored Content
Full Discussion: Substring HELP!
Top Forums Shell Programming and Scripting Substring HELP! Post 302239010 by awknerd on Monday 22nd of September 2008 05:12:42 PM
Old 09-22-2008
Error Substring HELP!

Hi,

I am trying to do something which I thought was very simple but still being a beginner, has proved not to be.

Input:

val1 val2 val3 val4 val5 val6
.
.
.
etc

Desired Output:

Every row in which value of val6 is a number starting with 0.0 or contains a capital E. The input is in .tab format

Sample:

INPUT:

val1 val2 val3 val4 val5 0.123
val1 val2 val3 val4 val5 0.01456
val1 val2 val3 val4 val5 0.000123
val1 val2 val3 val4 val5 0.0123
val1 val2 val3 val4 val5 3.2E-52
val1 val2 val3 val4 val5 0.153
val1 val2 val3 val4 val5 1

OUTPUT:

val1 val2 val3 val4 val5 0.01456
val1 val2 val3 val4 val5 0.000123
val1 val2 val3 val4 val5 0.0123
val1 val2 val3 val4 val5 3.2E-52


I have tried various scripts, all gave me errrors or didn't stop running.

I've tried

#!/bin/bash

for f in input.tab
do
awk ' c==substr($6, 1, 3)
if c==0.0 || E
print c'
done


I know this doesn't work, and I really need help. That would be very appreciated. Thanks!!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

substring

Hi, I have a value of a filepath in a variable DATAFILE with value as "customtop/gpsore37/gepspo/1.0/bin/ashoka.csv ". Now i want the value of last 4 charcters in to another variable. That is EXTENSION = .csv How can i do this in Shell scripting Thanks in advance Alla Kishore (8 Replies)
Discussion started by: alla.kishore
8 Replies

2. Shell Programming and Scripting

How do I Substring ??

Hello everyone. I'm writing a script in UNIX. The purpose is to get the second character from a variable that stores the system year. This is the code: unix_year_yy=`date "+%g"` This will return "07" in variable unix_year_yy. How can I get the second character (7)?? (6 Replies)
Discussion started by: Rigger
6 Replies

3. Shell Programming and Scripting

substring

Dear All, i have a file that contains, FROM_DATE: 06-08-2007 00:00:00 TO_DATE: 06-08-2007 23:59:59 Total number of lines: 6874154 in another file,the contain is, FROM_DATE: 06-08-2007 00:00:00 Total number of lines: 874154 alltime i want to find the particular string... (4 Replies)
Discussion started by: panknil
4 Replies

4. Shell Programming and Scripting

substring ??

I execute command on this file and it gives o/p like this. COMMAND $ fuser -f /clocal/sanjay/AccessMonitor /clocal/sanjay/AccessMonitor: 1368322c To truncate 'c', i used tr -dc "\n" but then it does't give 1368322 as O/P. Any help ?? (7 Replies)
Discussion started by: varungupta
7 Replies

5. UNIX for Dummies Questions & Answers

Need help with substring

I need to check the occurrence of one string within another. code ******************** if ;then do something done ******************** Thanks (7 Replies)
Discussion started by: w020637
7 Replies

6. UNIX for Dummies Questions & Answers

Substring

Hi I use the below cmd to get the list of files that are modified than <temp> file in the <path> diretory cmd:find <path> -name '*.zip' -type f -newer <temp> -print i am getting all the list of files that are new or modified, with abs path, i want to copy all of these files to a... (3 Replies)
Discussion started by: Naveen_5960
3 Replies

7. Shell Programming and Scripting

substring

I have a string '<Hi>abc</Hi>" How to print "abc" (6 Replies)
Discussion started by: sandy1028
6 Replies

8. UNIX for Dummies Questions & Answers

Getting Substring

Hi, I hav a string lets say aa.txt:bb:txt length of the string can vary.. I have to keep the token inside a array and the delimiter is : plz send me the code (2 Replies)
Discussion started by: Deekay.p
2 Replies

9. Shell Programming and Scripting

Get the substring

Hi All, I have a ouput string likes 'u8wos' or 'u10acsd' or somthing else 'u{number}{any characters}'and I want to get the number behind the letter 'u' by bash shell. Thanks Damon (11 Replies)
Discussion started by: Damon_Qu
11 Replies

10. Shell Programming and Scripting

Substring

Hi All, In ksh, am trying to get a substring stuff done. Not sure where the problem is.. can you guys guide me on this... for instance, var1=41, and var2=4175894567, then i want to know whether var2 starts with var1.. var1 and var2 can be of any length.. VAR1=41 VAR2=419068567777... (6 Replies)
Discussion started by: nram_krishna@ya
6 Replies
NCFLINT(1)						      General Commands Manual							NCFLINT(1)

NAME
ncflint - netCDF File Interpolator SYNTAX
ncflint [-3] [-4] [-6] [-A] [-C] [-c] [-D dbg] [-d dim,[ min][,[ max]]] [-F] [-h] [-i var,val3][-L dfl_lvl][-l path] [-O] [-p path] [-R] [-r] [-t thr_nbr] [-v var[,...]] [-w wgt[, wgt2]] [-X box] [-x] file1 file2 file3 DESCRIPTION
ncflint creates an output file that is a linear combination of the input files. This linear combination can be a weighted average, a nor- malized weighted average, or an interpolation of the input files. Coordinate variables are not acted upon in any case, they are simply copied from file_1. There are two conceptually distinct methods of using ncflint. The first method is to specify the weight each input file is to have in the output file. In this method, the value val3 of a variable in the output file file_3 is determined from its values val1 and val2 in the two input files according to wgt1*val1+wgt2*val2 Here at least wgt1, and, optionally, wgt2, are specified on the command line with the -w (or --weight or --wgt_var ) switch. If only IR wgt1 is specified then wgt2 is automatically computed as wgt2=1-wgt1. Note that weights larger than 1 are allowed. Thus it is possible to specify wgt1=2 and wgt2=-3. One can use this functionality to multiply all the values in a given file by a constant. The second method of using ncflint is to specify the interpolation option with -i (or with the --ntp or --interpolate long options). This is really the inverse of the first method in the following sense. When the user specifies the weights directly, ncflint has no work to do besides multiplying the input values by their respective weights and adding the results together to produce the output values. This assumes it is the weights that are known a priori. In another class of cases it is the "arrival value" (i.e., val3 ) of a particular vari- able var that is known a priori. In this case, the implied weights can always be inferred by examining the values of var in the input files. This results in one equation in two unknowns, wgt1 and wgt2: val3=wgt1*val1+wgt2*val2. Unique determination of the weights requires imposing the additional constraint of normalization on the weights: wgt1+wgt2=1. Thus, to use the interpolation option, the user specifies var and val3 with the -i option. ncflint will compute wgt1 and wgt2, and use these weights on all variables to generate the output file. Although var may have any number of dimensions in the input files, it must represent a single, scalar value. Thus any dimensions associated with var must be "degenerate", i.e., of size one. If neither -i nor -w is specified on the command line, ncflint defaults to weighting each input file equally in the output file. This is equivalent to specifying -w0.5 or -w0.5,0.5. Attempting to specify both .BR -i and -w methods in the same command is an error. ncflint is programmed not to interpolate variables of type NC_CHAR and NC_BYTE. This behavior is hardcoded. AUTHOR
NCO manual pages written by Charlie Zender and Brian Mays. REPORTING BUGS
Report bugs to <http://sf.net/bugs/?group_id=3331>. COPYRIGHT
Copyright (C) 1995-2010 Charlie Zender This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for NCO is maintained as a Texinfo manual called the NCO User's Guide. Because NCO is mathematical in nature, the documentation includes TeX-intensive portions not viewable on character-based displays. Hence the only complete and authoritative versions of the NCO User's Guide are the PDF (recommended), DVI, and Postscript versions at <http://nco.sf.net/nco.pdf>, <http://nco.sf.net/nco.dvi>, and <http://nco.sf.net/nco.ps>, respectively. HTML and XML versions are available at <http://nco.sf.net/nco.html> and <http://nco.sf.net/nco.xml>, respectively. If the info and NCO programs are properly installed at your site, the command info nco should give you access to the complete manual, except for the TeX-intensive portions. HOMEPAGE
The NCO homepage at <http://nco.sf.net> contains more information. NCFLINT(1)
All times are GMT -4. The time now is 01:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy