Sponsored Content
Top Forums Shell Programming and Scripting Problem in tokenizing the string Post 302631183 by saurabhkoar on Friday 27th of April 2012 02:52:56 AM
Old 04-27-2012
Actually I don't want to print in that format. I want the corresponding variables variables assigned to the corresponding value. As I will need the variables further. Like I want servicename variable assigned to DNS. So, if I do echo $servicename, it will print DNS. If I do echo $password it will print pwd, if I do echo $username it will print cn=user1,o=company.

So, I did something like this:

Code:
echo "DNS = cn=user1,o=company : pwd" | awk -F"[=:]" '{servicename="$1"; password="$NF"}{sub($1"=","");sub(":"$NF,"");Username="$0"}'

And then tried echo. But it didn't print anything. Please correct me where I am wrong.

Moderator's Comments:
Mod Comment Please use [code][/code] tags. Video tutorial on how to use them

Last edited by Scrutinizer; 04-27-2012 at 05:14 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

An Idea for Tokenizing

One of the monitoring tools in Java is called `jps`, and it monitors all Java processes that are run by the user, an example output would be like this: 3459 Jps 2348 test 2311 Util where the first column represents Process IDs and the second column represents Java processes names.... (8 Replies)
Discussion started by: neked
8 Replies

2. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

3. UNIX for Dummies Questions & Answers

problem with if -z string

someone please help me out here. i am not a newbie. i just haven't posted on this board in years. i'm talking at least two and a half years. My last user name was TRUEST. i couldn't log into this name because i forgot my password and my aol email address has long been deleted. anyway, i'm... (1 Reply)
Discussion started by: Terrible
1 Replies

4. Programming

Problem returning string

Hi all, I have been trying with RSA encryption and decryption. I was able to write a code which worked fine. Then I split it into functions as part of a requirement. However I am not getting the expected result everytime. I know it has something to do with how I am returning but it just does not... (1 Reply)
Discussion started by: Treasa
1 Replies

5. Shell Programming and Scripting

Tokenizing a String in unix

Hi All, I have String i want to tokenize based on one delimiter. Original String is -pComments.properties,-iPELF4 i want to tokenize the original string based on ',' (comma) as delimiter and collect them individually like string1=-pComments.properties string2=-iPELF4 ... (1 Reply)
Discussion started by: rajeshorpu
1 Replies

6. Shell Programming and Scripting

Runaway String Problem

Database.txt John:30:40 echo -n "New Title Please :" read NewTitle awk -F":" 'OFS = ":"{ $1 = "'$NewTitle'" ; print $0 } ' Database.txt> Database2.txt mv Database2.txt Database.txt what this does, is that when i input something into $NewTitle, it will update $1 which is "John" into... (3 Replies)
Discussion started by: gregarion
3 Replies

7. Shell Programming and Scripting

string tokenizing

I have a string that looks like this: blahblahblah_^substring^_blahblahblah I need to extract substring, the bit between the ^ characters, into another string variable. This will be in a bash shell script. Thanks. (2 Replies)
Discussion started by: daflore
2 Replies

8. Shell Programming and Scripting

if PATH contains a certain string problem!

Hi I am using MKS Toolkit c shell. I want to basically check if my PATH variable already contains a certain path directory so I tried this (it didnt work!): if: Expression Syntax if ( echo $path |grep -c c:/PROGRA~1/blah/blah ) then please help me get this little statement to work. ... (3 Replies)
Discussion started by: vas28r13
3 Replies

9. Shell Programming and Scripting

Problem in comparing 2 files string by string

Hi Champs, I am a newbie to unix world, and I am trying to built a script which seems to be far tough to be done alone by me..... " I am having a raw csv file which contains around 50 fields..." From that file I have to grep 2 fields "A" and "B"....field "A" is to be aligned vertically... (11 Replies)
Discussion started by: jitendra.pat04
11 Replies

10. Shell Programming and Scripting

Parsing a long string string problem for procmail

Hi everyone, I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email. Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string. GetRyt... (4 Replies)
Discussion started by: cwiggler
4 Replies
Net::DNS::RR::NSAP(3)					User Contributed Perl Documentation				     Net::DNS::RR::NSAP(3)

NAME
Net::DNS::RR::NSAP - DNS NSAP resource record SYNOPSIS
"use Net::DNS::RR"; DESCRIPTION
Class for DNS Network Service Access Point (NSAP) resource records. METHODS
idp print "idp = ", $rr->idp, " "; Returns the RR's initial domain part (the AFI and IDI fields). dsp print "dsp = ", $rr->dsp, " "; Returns the RR's domain specific part (the DFI, AA, Rsvd, RD, Area, ID, and SEL fields). afi print "afi = ", $rr->afi, " "; Returns the RR's authority and format identifier. "Net::DNS" currently supports only AFI 47 (GOSIP Version 2). idi print "idi = ", $rr->idi, " "; Returns the RR's initial domain identifier. dfi print "dfi = ", $rr->dfi, " "; Returns the RR's DSP format identifier. aa print "aa = ", $rr->aa, " "; Returns the RR's administrative authority. rsvd print "rsvd = ", $rr->rsvd, " "; Returns the RR's reserved field. rd print "rd = ", $rr->rd, " "; Returns the RR's routing domain identifier. area print "area = ", $rr->area, " "; Returns the RR's area identifier. id print "id = ", $rr->id, " "; Returns the RR's system identifier. sel print "sel = ", $rr->sel, " "; Returns the RR's NSAP selector. NOTE
COPYRIGHT
Copyright (c) 1997-2002 Michael Fuhr. Portions Copyright (c) 2002-2004 Chris Reinhardt. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.. SEE ALSO
perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC 1706. perl v5.18.2 2014-01-16 Net::DNS::RR::NSAP(3)
All times are GMT -4. The time now is 01:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy