Sponsored Content
Full Discussion: awk searching
Top Forums Shell Programming and Scripting awk searching Post 302426948 by manzi on Thursday 3rd of June 2010 10:39:52 AM
Old 06-03-2010
hi,

dont work the code.

this is the file example:

my file name 20100526_113020_ok. the red number is my result.

2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,568,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,1266,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,449,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,569,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,768,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,1268,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,344,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,
2470,XXXXXXXXXXX,5-26-2010,37091,5-26-2010,55091,202,304,128D5313490C0A89FFFFFFFFEE9C957D,10465,0,0,0,668,,269,0,0,0,701,1001,101,-1,0, ,0,269,35,3/6/2009 15:8:0,1/1/1900 0:0:0,3/6/2009 15:8:0,0,0,0,0,,0,0,0,0,0,0,1,2,5,213,998252,50,-1,0,XXXXXXXXXXXXX,740010126242881,XXXXXXXXXXX,2,1,740010124932418,

i execute

Code:
> awk -F, '$12~/68 *$/  {print}' 20100526*

but result is prompt >

doesnt work.

thanks

regards!

Last edited by manzi; 06-03-2010 at 11:47 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching for + sign in a string using awk

Hi All, My query is: I have string say xyz+ how to determine that whether it ends with a + sign or not using awk command. (5 Replies)
Discussion started by: satyajit2512
5 Replies

2. Shell Programming and Scripting

awk searching between two files

hi there, im writing some script in awk; in few words i have a list from router (mac address- ip address) and the second list with only the mac addresses. the thing is that i want search list from router for the first mac address; if found - print the ip address, if not print error; then search... (1 Reply)
Discussion started by: mac7
1 Replies

3. Shell Programming and Scripting

Searching word in a file with awk

Hello everyone! I use a script to query for installed packages with yum (I use RHEL 4 with yum installed) and the output is redirected to a file. My script scan this file to find a package and the version of it. The script works fine until I search for a package name with special characters.... (3 Replies)
Discussion started by: studieu
3 Replies

4. Shell Programming and Scripting

awk and searching within a block ?

Hi, I wonder if anybody could help. How do i awk out (or indeed using another utility) a particular value that exists within a defined block, for example if i have a file that looks like the one below and i want to get at the "Product Serial" for the block referring to "mb.fru" (bolded and coloured... (4 Replies)
Discussion started by: rethink
4 Replies

5. Shell Programming and Scripting

Searching using awk - Help required

Hi... I am working on script to search some records in a file based on certain fields and each record is a ASCII fixed size. I was using awk to search based on certain condition. But the length of the record is too much that awk is giving syntax error near unexpected token `(' Request... (5 Replies)
Discussion started by: ysrikanth
5 Replies

6. Shell Programming and Scripting

Searching a file using awk or sed

I want to search a file in a specific location and I don't want to use find command. I want to give the path also where the file is for searching it. Pls help (3 Replies)
Discussion started by: maitree
3 Replies

7. Shell Programming and Scripting

awk: searching for non-breaking-space

This code shal search for the non-breaking space 0xA0 though it returns the error "fatal: attempt to use scalar 'nbs' as array" Can somebody help? awk --non-decimal-data -v nbs="0xA0" '{if($0 in nbs) {print FILENAME, NR}}' *.txt (1 Reply)
Discussion started by: sdf
1 Replies

8. Shell Programming and Scripting

Searching multiple patterns using awk

Hello, I have the following input file: qh1adm 20130710111201 : tp import all QH1 u6 -Dsourcesystems=BFI,EBJ qh1adm 20130711151154 : tp import all QH1 u6 -Dsourcesystems=BFI,EBJ qx1adm 20130711151154 : tp count QX1 u6 -Dsourcesystems=B17,E17,EE7 qh1adm 20130711151155 : tp import all... (7 Replies)
Discussion started by: kcboy
7 Replies

9. Shell Programming and Scripting

Searching value in table through awk

I need to create one script in which I want to search in txt file , this txt file is having 10 columns , I want to check 4th column value if "BOY" & 10th column value =>500 it will print 4th column row value ,1st column row value & 10th column row value & store the same value in one file as... (2 Replies)
Discussion started by: dravi_laxmi
2 Replies

10. Shell Programming and Scripting

Searching content of a variable using awk

so i'm running a variation of the following command a few times in my script: echo "${TOTALRunning}" | awk -F"" '/'"${PROCSEARCH}"'/ {print $2}' | tr '\n' '|' unfortunately i cant paste the content of the variable TOTALRunning into this thread for security reasons. what i want to do is... (9 Replies)
Discussion started by: SkySmart
9 Replies
A2P(1)							 Perl Programmers Reference Guide						    A2P(1)

NAME
a2p - Awk to Perl translator SYNOPSIS
a2p [options] filename DESCRIPTION
A2p takes an awk script specified on the command line (or from standard input) and produces a comparable perl script on the standard out- put. Options Options include: -D<number> sets debugging flags. -F<character> tells a2p that this awk script is always invoked with this -F switch. -n<fieldlist> specifies the names of the input fields if input does not have to be split into an array. If you were translating an awk script that processes the password file, you might say: a2p -7 -nlogin.password.uid.gid.gcos.shell.home Any delimiter can be used to separate the field names. -<number> causes a2p to assume that input will always have that many fields. -o tells a2p to use old awk behavior. The only current differences are: o Old awk always has a line loop, even if there are no line actions, whereas new awk does not. o In old awk, sprintf is extremely greedy about its arguments. For example, given the statement print sprintf(some_args), extra_args; old awk considers extra_args to be arguments to "sprintf"; new awk considers them arguments to "print". "Considerations" A2p cannot do as good a job translating as a human would, but it usually does pretty well. There are some areas where you may want to examine the perl script produced and tweak it some. Here are some of them, in no particular order. There is an awk idiom of putting int() around a string expression to force numeric interpretation, even though the argument is always inte- ger anyway. This is generally unneeded in perl, but a2p can't tell if the argument is always going to be integer, so it leaves it in. You may wish to remove it. Perl differentiates numeric comparison from string comparison. Awk has one operator for both that decides at run time which comparison to do. A2p does not try to do a complete job of awk emulation at this point. Instead it guesses which one you want. It's almost always right, but it can be spoofed. All such guesses are marked with the comment ""#???"". You should go through and check them. You might want to run at least once with the -w switch to perl, which will warn you if you use == where you should have used eq. Perl does not attempt to emulate the behavior of awk in which nonexistent array elements spring into existence simply by being referenced. If somehow you are relying on this mechanism to create null entries for a subsequent for...in, they won't be there in perl. If a2p makes a split line that assigns to a list of variables that looks like (Fld1, Fld2, Fld3...) you may want to rerun a2p using the -n option mentioned above. This will let you name the fields throughout the script. If it splits to an array instead, the script is probably referring to the number of fields somewhere. The exit statement in awk doesn't necessarily exit; it goes to the END block if there is one. Awk scripts that do contortions within the END block to bypass the block under such circumstances can be simplified by removing the conditional in the END block and just exiting directly from the perl script. Perl has two kinds of array, numerically-indexed and associative. Perl associative arrays are called "hashes". Awk arrays are usually translated to hashes, but if you happen to know that the index is always going to be numeric you could change the {...} to [...]. Itera- tion over a hash is done using the keys() function, but iteration over an array is NOT. You might need to modify any loop that iterates over such an array. Awk starts by assuming OFMT has the value %.6g. Perl starts by assuming its equivalent, $#, to have the value %.20g. You'll want to set $# explicitly if you use the default value of OFMT. Near the top of the line loop will be the split operation that is implicit in the awk script. There are times when you can move this down past some conditionals that test the entire record so that the split is not done as often. For aesthetic reasons you may wish to change the array base $[ from 1 back to perl's default of 0, but remember to change all array sub- scripts AND all substr() and index() operations to match. Cute comments that say "# Here is a workaround because awk is dumb" are passed through unmodified. Awk scripts are often embedded in a shell script that pipes stuff into and out of awk. Often the shell script wrapper can be incorporated into the perl script, since perl can start up pipes into and out of itself, and can do other things that awk can't do by itself. Scripts that refer to the special variables RSTART and RLENGTH can often be simplified by referring to the variables $`, $& and $', as long as they are within the scope of the pattern match that sets them. The produced perl script may have subroutines defined to deal with awk's semantics regarding getline and print. Since a2p usually picks correctness over efficiency. it is almost always possible to rewrite such code to be more efficient by discarding the semantic sugar. For efficiency, you may wish to remove the keyword from any return statement that is the last statement executed in a subroutine. A2p catches the most common case, but doesn't analyze embedded blocks for subtler cases. ARGV[0] translates to $ARGV0, but ARGV[n] translates to $ARGV[$n]. A loop that tries to iterate over ARGV[0] won't find it. ENVIRONMENT
A2p uses no environment variables. AUTHOR
Larry Wall <larry@wall.org> FILES
SEE ALSO
perl The perl compiler/interpreter s2p sed to perl translator DIAGNOSTICS
BUGS
It would be possible to emulate awk's behavior in selecting string versus numeric operations at run time by inspection of the operands, but it would be gross and inefficient. Besides, a2p almost always guesses right. Storage for the awk syntax tree is currently static, and can run out. perl v5.8.0 2002-06-01 A2P(1)
All times are GMT -4. The time now is 04:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy