Wildcards when using awk -F


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Wildcards when using awk -F
# 1  
Old 10-17-2017
Wildcards when using awk -F

Trying to filter information when using awk -F. I'm trying to use wildcards to match a range of values but can't get the syntax to work.

Since I'm using awk -F I'm setting my delimiter then entering specific information abcde but if I want to do abcd(e-9) how do I make that work? Do I place the escape character in the quotes?

Any help is appreciated

Last edited by rbatte1; 10-17-2017 at 08:20 AM.. Reason: Added ICODE tags for clarity
fgarvis88
# 2  
Old 10-17-2017
Welcome fgarvis88,

I have a few to questions pose in response first:-
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
Most importantly, What have you tried so far?



We're all here to learn and getting the relevant information will help us all.

Kind regards,
Robin
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 10-17-2017
I have tried using abcd..., abcd...*, ^abcd, /abcd...\, abcd/e-9\ basically just different combinations to get it to filter what I want but to no avail.

When I don't use proper syntax I either get an error message with a "^" pointing to the place where the syntax goes wrong or it just hangs up and sits there in a loop and I escape out of it to try again.

I'm fairly new to this and regex/syntax aren't my strongest suit.

Using 14.04.01 Ubuntu

---------- Post updated at 06:43 AM ---------- Previous update was at 06:33 AM ----------

Also if you want to message me I'm open to that. I can't send messages since I'm such a noob :)

---------- Post updated at 06:47 AM ---------- Previous update was at 06:43 AM ----------

I also thought it may be easier to set a variable for what I'm looking for and stick it in there. I haven't set variables using awk before but that might be the more efficient way to go.

Last edited by rbatte1; 10-17-2017 at 10:11 AM.. Reason: Added ICODE tags
fgarvis88
# 4  
Old 10-17-2017
-F is for specifying field separators. It's not intended to match strings. That's something you would do in the awk itself. -F can be ranges (of characters), for example -F "[a-e0-9]" would identify any character a through e, and 0 through 9 in the input as a field separators. But I doubt that's what you really want to do.

What exactly are you trying to do (without trying to tell us how you're doing it, because I think that's confusing us, well me anyway!)? It would help if you gave, also, a sample of the input file you using.
This User Gave Thanks to Scott For This Post:
# 5  
Old 10-17-2017
Right, I'm using -F so I can filter on particular fields. This is a SecOnion VM so I'm trying to use some sort of wildcard combo to filter certain octets of an IP address of web traffic.

For instance I'm looking at http traffic but I want to see 5 or 6 fields so I can focus on who is talking to who. I want to filter out a range of IP's that take up a bulk of the traffic so I can focus on the onesies and twosies easier.

Last edited by rbatte1; 10-17-2017 at 10:12 AM.. Reason: Added ICODE tags
fgarvis88
# 6  
Old 10-17-2017
Please become accustomed to provide decent context info of your problem.

It is always helpful to carefully and detailedly phrase a request, and to support it with system info like OS and shell, related environment (variables, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two including your own attempts at a solution, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - index and wildcards

When I search for the string capId=... using awk '/capId=.../' file I get successful results. However when I feed the string as a variable, like this: str="capId=..." awk -v str="$str" 'index($0, str)' file I get no results. What can I do if I need to generate a string that contains... (1 Reply)
Discussion started by: locoroco
1 Replies

2. Shell Programming and Scripting

Using Wildcards in scp

to scp using windcards you use the following : scp 'hostname:/home/username/diff_201110*' . Enjoy ! (0 Replies)
Discussion started by: phpsnook
0 Replies

3. UNIX for Dummies Questions & Answers

For loop with wildcards

Hi, I've got a ksh for loop with wildcards specified, and I want the wildcards to be preserved when inside the loop. Instead, it is expanding the wilcards and identifying filenames in the current directory #!/usr/bin/ksh list="a* b*" for i in ${list} do echo 'Loop value =' ${i} done... (2 Replies)
Discussion started by: nim
2 Replies

4. UNIX for Advanced & Expert Users

Wildcards

These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all. GNU/Linux Command-Line Tools Guide - Wildcards GREP (1 Reply)
Discussion started by: cokedude
1 Replies

5. UNIX for Dummies Questions & Answers

SED and wildcards

I am using this code to locate and modify one particular ID in a file containing thousands of entries sed 's/^>OldID/>NewID/g' Infile > Outfile How can I modify the code so I can rename all old IDs to a new unique ID? I tried this sed 's/^>*/>NewID/g' Infile > Outfile but it did not... (10 Replies)
Discussion started by: Xterra
10 Replies

6. UNIX for Dummies Questions & Answers

wildcards NOT

Hi All Please excuse another straightforward question. When creating a tar archive from a directory I am attempting to use wildcards to eliminate certain filetypes (otherwise the archive gets too large). So I am looking for something along these lines. tar -cf archive.tar * <minus all *.rst... (5 Replies)
Discussion started by: C3000
5 Replies

7. UNIX for Dummies Questions & Answers

ls with wildcards

ok, I'm trying to write a script file that lists files with specific elements in the name into a txt file, it looks like this ls s*.dat > file_names.txt can't figure out whats wrong with that line, any ideas? thanks in advance (10 Replies)
Discussion started by: benu302000
10 Replies

8. UNIX for Dummies Questions & Answers

wildcards

when writing a shell script (bourne) and using a unix command like 'ls' is there anything special you need to do to use a wildcard (like *)? (3 Replies)
Discussion started by: benu302000
3 Replies

9. UNIX for Dummies Questions & Answers

grep and wildcards

Hi guys, a small problem today, I'm grepping a log file containing lines like this below: Mar 09 16:04:00 blabla Mar 09 16:04:02 blabla Mar 09 16:04:05 blabla Mar 09 16:04:15 blabla Mar 09 16:05:06 blabla Mar 09 16:05:23 blabla Mar 09 16:05:25 blabla ... in this file I'm grepping... (5 Replies)
Discussion started by: Lomic
5 Replies

10. UNIX for Dummies Questions & Answers

Wildcards in VI

I'm trying to delete lines from a large text file using VI. Every line that I am wanting to delete start with 'S' - all others do not. (A list of users) I've tried using * but doesn't seem to like it...any ideas... Doesn't have to be VI - but I'm better with VI than sed/awk. (8 Replies)
Discussion started by: peter.herlihy
8 Replies
Login or Register to Ask a Question