1. There should be a space between awk and -F
2. There should be no space between $ and 12
3. Since the field can be 3 or 4 characters I would not use substr , but use a pattern match:
4. Use curly braces instead of parentheses in most places
5. If you use 20100525 * it means read file named "20100525" and subsequently read any file in the directory including file "20100525"for the second time if it exists. Do you mean 20100525* (any file that begins with 20100525)?
After applying these changes you end up with something like this:
... hi all
unexpected results..
i extract the file info is very extense.... the strings exits in the file but have 3 or 4 characters
example
1268
368
try the easy example
Code:
awk -F, '$12~/68$/ {print}' 20100525*
the result is root Prompt >
...
Well, can you cut/paste the portion of your file that you expect to be captured by the awk script ?
The awk one-liner works well with my test files.
Code:
$
$
$ # how many files have names starting with "20100525" ?
$ ls -1 20100525*
20100525_myfile1.txt
20100525_myfile2.txt
$
$
$ # show the contents of both these files
$ cat 20100525_myfile1.txt
1,2,3,4,5,6,7,8,9,10,11,1267,13,14
1,2,3,4,5,6,7,8,9,10,11,1268,13,14
1,2,3,4,5,6,7,8,9,10,11,1269,13,14
$
$ cat 20100525_myfile2.txt
1,2,3,4,5,6,7,8,9,10,11,367,13,14
1,2,3,4,5,6,7,8,9,10,11,368,13,14
1,2,3,4,5,6,7,8,9,10,11,369,13,14
$
$ # now run the awk one-liner on these files
$ awk -F, '$12~/68$/ {print}' 20100525*
1,2,3,4,5,6,7,8,9,10,11,1268,13,14
1,2,3,4,5,6,7,8,9,10,11,368,13,14
$
$ # the result is as expected
$
Just a thought - maybe you have white space at the end of the 12th field, after "68" and before the 12th comma ?
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)
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)
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)
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)
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)
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)
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)
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)