pulling out the value from rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pulling out the value from rows
# 1  
Old 01-22-2010
pulling out the value from rows

Hi,

I'm trying to pull all occurrence of value , for example "xy1234" from several rows, out of a file. The file might as well contain other different type of rows.

Code:
20100121 04:00:02 37a00452 <ABCN:ABXC> From MV Modify <uid=xy1234,ou=Internal2,ou=people,dc=abc,dc=example1,dc=com>

I am trying to write a perl script. Although, i can utilize "split" functionality, but i'm not able to come up a using a delimeter.

Please help.

Thanks, Prince
# 2  
Old 01-22-2010
Code:
echo '20100121 04:00:02 37a00452 <ABCN:ABXC> From MV Modify <uid=xy1234,ou=Internal2,ou=people,dc=abc,dc=example1,dc=com>' | sed 's/.*uid=\([^,][^,]*\).*/\1/'

# 3  
Old 01-22-2010
are you sure you want to do it using only perl.. because sed might help you..
# 4  
Old 01-22-2010
Another one with sed:
Code:
sed 's/.*uid=\([^,]*\).*/\1/'

or with awk:
Code:
awk -F"uid=|," '{print $2}'

# 5  
Old 01-22-2010
Thanks for all your reply.

I will be configuring this script on a window server, and there we don't have awk or sed utility installed.

Also, this is just a one of the several things, i have intended to do using a Perl script. So, i want to do this using perl utility like "split" etc.

Thanks, Prince
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Partial file pulling

I am connecting to another server through sftp. I am running one batch script to pull file from another server. sometimes i am receiving partial files. I am using below commands in batch script. ls -ltr new.txt mget new.txt bye The file is of 1 MB only.In most of the cases , i received... (6 Replies)
Discussion started by: srinath01
6 Replies

2. Shell Programming and Scripting

Pulling data from xml

Hi there, Please could anyone help with this. I have an xml file that contains repeating values eg <Rule name> AAAAA <Action> BBBBB </Action> <Data> CCCCC </Data> <Type> DDDDD </Type> </Rule name> <Rule name> A1A1A1A1 <Action> B1B1B1B1 </Action> <Data> C1C1C1C </Data> <Type>... (4 Replies)
Discussion started by: ssideel
4 Replies

3. UNIX for Dummies Questions & Answers

Pulling Parms from Config File

Hello all, I'm working on a general script for something at work. I'm an up-and-comer backup for a Shell Scripter this company has had for 35 years lol. Anyway, I have a config file I'm trying to pull Variables from as the Config File is used for multiple scripts. Does the below make sense and... (7 Replies)
Discussion started by: phunk
7 Replies

4. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

5. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

6. Shell Programming and Scripting

Pulling correct value from Mapfile

Hi all, I am trying to pull one value from a Mapfile, but the result is that I am getting all the values. The Mapfile maps the host name from the Backup Server to the host name in our Network Monitoring Server, as shown here: Mapfile cat zabbixhosts Helpdesk-fd:Server_Helpdesk... (4 Replies)
Discussion started by: MrKen
4 Replies

7. Shell Programming and Scripting

Capacity of directory... Pulling hair out :-)

I am new to scripting and thought I was doing rather well however I ran into a issue and I am not sure how to fix it. I am using the following command to obtain the capacity percent of the directory listed however it seems that this command gets the capacity of the whole mount rather then just the... (8 Replies)
Discussion started by: LRoberts
8 Replies

8. Shell Programming and Scripting

pulling a column from a file in ksh

I would like to pull a column from a file and place it in a variable: The file would look like this: N.Korea gibberish garbage S.Korea gibberish garbage USA gibberish garbage Iraq gibberish garbage Canada gibberish garbage and items in the first... (8 Replies)
Discussion started by: dangral
8 Replies

9. UNIX for Dummies Questions & Answers

pulling the following line from a file

I have return files from a process that has then original input record followed on the next line by a response record..either AA,........... for accepted or EE,.......... for errored. i.e 11,new,123 AA,accepted 12,exist,443 EE,rejected 13,old,223 AA,accepted I want to write a small... (4 Replies)
Discussion started by: peter.herlihy
4 Replies

10. UNIX for Advanced & Expert Users

Pulling out fields from a file

Hi, I have a file that contains 1400 lines similar to the one shown below: NAME=sara, TOWN=southampton, POSTCODE=SO18777, EMAIL=sara@hotmail.com, PASSWORD=asjdflkjds etc etc (note: this is one line). Each line has the same fields, but on each line they are in a different order. Eg. the line... (2 Replies)
Discussion started by: Saz
2 Replies
Login or Register to Ask a Question