Newbie Help with Grep or Awk .. Easy one ...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Newbie Help with Grep or Awk .. Easy one ...
# 1  
Old 01-22-2009
Newbie Help with Grep or Awk .. Easy one ...

I have this output:

uniquemember=uid=315kthatch,ou=people,ou=client315,dc=paisleyhosting,dc=com

and i want the output to be just this:

315kthatch

I need it to be generic tho, because I have hundreds of lines of output, and the preceding numbers are not always 315. So I would need everything that equals "uid=*"
# 2  
Old 01-22-2009
YMMV:
Code:
echo 'uniquemember=uid=315kthatch,ou=people,ou=client315,dc=paisleyhosting,dc=com' | awk -F'[=,]' '{print $3}'

echo 'uniquemember=uid=315kthatch,ou=people,ou=client315,dc=paisleyhosting,dc=com' |sed 's/.*uid=\([^,][^,]*\).*/\1/'

# 3  
Old 01-22-2009
Thank you.
# 4  
Old 01-22-2009
I am not sure if you can use two characters as a delimiter in AWK. I would try this below to get the ids
echo 'uniquemember=uid=315kthatch,ou=people,ou=client315,dc=paisleyhosting,dc=com' | awk -F= '{print $3}'|awk -F, '{print $1}'
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Newbie looking for how to Grep times more than 10 seconds apart

I am new to grep and Linux and am looking to see if grep can parse out a list of lines that have a difference of more than 10 seconds between the times on each line. Example 2016-09-17 19:30:57 INFO: id: 4562079216, time: 2016-09-17 19:30:41, 2016-09-17 12:02:26 INFO: id:... (26 Replies)
Discussion started by: Markham
26 Replies

2. Shell Programming and Scripting

awk easy question

So, I have the following code: cat testfile.txt | awk -F, '{ print $1" "$2" "$3" "$4" "$5 }' | read DOC ORG NAME echo "$DOC" echo "$ORG" echo "$NAME" My testfile.txt looks something like the following: Document Type,Project Number,Org ID,Invoice Number It will eventually be more... (14 Replies)
Discussion started by: Parrakarry
14 Replies

3. UNIX for Dummies Questions & Answers

Should be an easy GREP question...

Two things. 1. I need to list all the jpg that start with a specific pattern and I tried using wildcards and can't get it to work. Basically: grep "cpd*.jpg" myfile.sgm return all entries that start with cpd (wildcard) and jpg but this does not work and I can't find another option--I'm... (4 Replies)
Discussion started by: jcor826
4 Replies

4. UNIX for Dummies Questions & Answers

Easy Grep Question

This seems like an easy question, but I can't find an answer already posted. I want a command to return all of the lines in a file containing exactly a string I tried grep -x "372701" x.txt but this did not return anything I am just trying to search a file for lines which contain... (4 Replies)
Discussion started by: jgrosecl
4 Replies

5. Shell Programming and Scripting

easy grep question

pattern matching porblem. I have a file with lines like this: hdisk2 blah 03 hdisk3 blah 03 hdisk21 blat 06 hdisk23 blah 06 hdisk210 blat 06 So I want to grep for just hdisk2, but I get back as you would expect hdisk2 dhsik21 hdisk23 hdisk210 I tried several... (1 Reply)
Discussion started by: adder2
1 Replies

6. Shell Programming and Scripting

AWK Help ME! this easy for who know

Friends; I have little experience with shell and I am not able to resolve this problem: file1: CRA-JJ-W980-01; 2009-11-24; GigabitEthernet; 0/0 CRA-JJ-W980-01; 2009-11-24; GigabitEthernet;1/0 CRA-JJ-W980-01;2009-11-24;GigabitEthernet;3/0... (5 Replies)
Discussion started by: He2
5 Replies

7. UNIX for Dummies Questions & Answers

Simple newbie grep question

How come grep testfile1 won't find anything in testfile1 (even though the characters sd are there in great quantity), but grep '' testfile1 will find plenty? Do the single quotes prevent the shell from interpreting the testfile1 is interpreted as: grep *test whether or not characters sd exist*... (5 Replies)
Discussion started by: doubleminus
5 Replies

8. Shell Programming and Scripting

Newbie with an easy question

I'm looking to write a script that takes a certain directory and gzips all its files that are older than 2 days. I've done some research but for the life of me, I can't even get any files gzipped. Any help would be greatly appreciated! (3 Replies)
Discussion started by: adrockrocks
3 Replies

9. Shell Programming and Scripting

GREP Searching for a newbie...

Hi, I really need some help with GREP searching... I need to find all occurances of a file reference and remove two characters from the end of the reference. For example, here are a few lines showing the text: <image file="STRAIGHT_004CR.jpg" ALT="STRAIGHT_004CR.jpg" /> <image... (8 Replies)
Discussion started by: steveglevin
8 Replies

10. UNIX for Dummies Questions & Answers

Need help on installing an EASY to use and easy to install command line text editor

Hi again. Sorry if it seems like I'm spamming the boards a bit, but I figured I might as well ask all the questions I need answers to at once, and hopefully at least get some. I have installed Solaris 10 on a server. The default text editors are there (vi, ex, ed, maybe others, I know emacs is... (4 Replies)
Discussion started by: EugeneG
4 Replies
Login or Register to Ask a Question