Need some help extracting a GUID from file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need some help extracting a GUID from file
# 1  
Old 08-31-2011
Need some help extracting a GUID from file

I'm fairly new to scripting, and need some help in extracting a piece of data from some output I have. This is what the original output looks like:

HTML Code:
| GUID                             | C1           | C2           |      C3             |
| bc3c0e68f85f45b09f2fec225d516a34 | jim          | Unknown      |                     |
| 7f2f0ab07f1e4dd6b50990b1c2a2b420 | bob          | Unknown      |                     |
| d24828318c3a4ff38bed64c5aef1a6f3 | jimbob       | Unknown      |                     |
| 04c7c914b6604bd9818867b7a12fd5ed | captain jack | Unknown      |                     |

What I need to get is just the 32 character GUID extracted. I've got this command, and it works, but it's ugly:

cat inputfile |sed '1,3d' |sed '$d' |cut -d' ' -f2 |cut -c 1-32

Any other suggestions?
# 2  
Old 08-31-2011
You can lose one thing off the pipe chain right from the start by getting rid of the cat. You never needed it.

Is this mysql output? You can give mysql the --batch and --skip-column-names option to make the output much more scriptable.

If you're forced to use the output as is:

awk '/^| [0-9a-f][0-9a-f]/ { print $2 }' < inputfile > outputfile

# 3  
Old 08-31-2011
Yeah, it is mysql output, but the command is already formatted as such. Too much work to actually go into mysql to get the data if it's readily available.

Thanks for the help. I think I need to take "awk/sed scripting 99".
# 4  
Old 09-01-2011
$ nawk -F\| '{print $2}' inputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

tar file help and uid guid?

when I executed tar xvf jre-7u7-soloris-i586.tar.gz it created the last entry with user as 10 and group as 143. When I execute the cd to the jrel directory I get directory not found error. Not sure why this is happening. I am in the root account just trying to install Java Enterprise. ... (2 Replies)
Discussion started by: Fingerz
2 Replies

2. UNIX for Dummies Questions & Answers

Difference between normal Execute permission and GUID

Hi, Any can explain the difference between the normal execute permission for the file and GUID of the file. Since the normal execute permission has right to execute file why there is need of providing GUID for the same file. Also share some examples for SUID and SGID programs. Regards... (3 Replies)
Discussion started by: ksgnathan
3 Replies

3. AIX


Hi, I am harsath , am new to UNIX- Aix ust started to learning , interested in working with servers , is it necessary to know shell scripting before learning aix, will i get job only if i know aix .... pls reply..... Thanks in advance.... (2 Replies)
Discussion started by: harsath24330
2 Replies

4. Shell Programming and Scripting

Extracting a column from a file and merging with other file using awk

Hi All: I have following files: File 1: <header> text... text .. text .. text .. <\header> x y z ... File 2: <header> text... text .. text .. (4 Replies)
Discussion started by: mrn006
4 Replies

5. UNIX for Dummies Questions & Answers

what is SUID,GUID and Sticky bit?

Dear all, what is SUID,GUID and Sticky bit permission? can anyone gave me explanation with example? thanks in advance.. (2 Replies)
Discussion started by: masthan25
2 Replies

6. UNIX for Advanced & Expert Users

preserve guid:uid tar / cp

hello, i've a backup of a xen image which was tar'ed. i extracted the tarfile with --preserve and moved it to the lvm partition useing cp -p to preserve the ownership informations of the files in this step too. but unfortunatly after extracting the archive some uid and guids which are present... (5 Replies)
Discussion started by: coffeecup
5 Replies

7. Solaris

setuid and guid

Hi All, Can someone give me some info about setuid or guid topic? Also about sticky bit. Thanks in advance, itik (9 Replies)
Discussion started by: itik
9 Replies

8. Shell Programming and Scripting

Parsing file, yaml file? Extracting specific sections

Here is a data file, which I believe is in YAML. I am trying to retrieve just the 'addon_domains" section, which doesnt seem to be as easy as I had originally thought. Any help on this would be greatly appreciated!! I have been trying to do this in awk and mostly bash scripting instead of perl... (3 Replies)
Discussion started by: Rhije
3 Replies

9. UNIX for Dummies Questions & Answers

what is SUID/GUID bits in UNIX/Solaris

Hi, I have a Oracle Database on Solaris 5.10 . Following file are showing with SUID/GUID bits . -rwsr-xr-x root dba /optware/oracle/ What will happen if this is changed to oracle dba . I need to know the will there be a effect if the owner of extjob is... (3 Replies)
Discussion started by: reply2soumya
3 Replies

10. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies
Login or Register to Ask a Question