Visit Our UNIX and Linux User Community


Tokenizing a String in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tokenizing a String in unix
# 1  
Old 11-03-2009
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


Please advice or send some sample code.

Thanks-
Raj
# 2  
Old 11-03-2009
cut ?
Code:
string1=$(echo $OriginalString | cut -d',' -f1)
string2=$(echo $OriginalString | cut -d',' -f2)


Previous Thread | Next Thread
Test Your Knowledge in Computers #456
Difficulty: Easy
An application programming interface (API) is a graphical-based interface for viewing client-server data.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search partial string in a file and replace the string - UNIX

I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this. string(Scenario 1)- user::r--,user::ourfrd:r-- String(Scenario 2)- user::r-- File **** # file: /local/Desktop/myfile # owner: me # group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies

2. Shell Programming and Scripting

String search in UNIX

Hi Team, Please help me with a command which greps the exact match of the string which I am searching in a file. For examplecat > file abc abcd def ghi In the above file I just wanted to display abc which is first entry. When I execute grep command cat file | grep "abc" it results... (3 Replies)
Discussion started by: madhuraju
3 Replies

3. Shell Programming and Scripting

Sub String in UNIX Script

Hi I have filenames coming as FILE.V<Version>.YYYYMMDD.z FILE.V260.20140423.z FILE.V1.20140523 FILE.V9999.20140324.z How do I extract the version number in a variable I need 260 1 9999 extracted into variable by Unix script (3 Replies)
Discussion started by: sparsh2012
3 Replies

4. Shell Programming and Scripting

Extract a string from another string in UNIX

I have a string string="Please have a nice day and sleep well Replace_12123_31233_32134_12342 Good day" How do i replace "Replace_12123_31233_32134_1234" in the above string.?? Please help. Regards, Qwerty (3 Replies)
Discussion started by: qwertyu
3 Replies

5. Shell Programming and Scripting

Problem in tokenizing the string

Supposed I have a string in the format: <service_name> = <ldap user FDN> : <password> like DNS = cn=user1,o=company : pwd I want to tokenize like: service name:DNS UserName: cn=user1,o=company Password: pwd. Because of the '=' sign between Service Name and LDAP Name I not... (8 Replies)
Discussion started by: saurabhkoar
8 Replies

6. Shell Programming and Scripting

string sorting in unix

Hi I need how to sort string characters for Example i have a file that contains this data example string "fan" but i want to display "afn" contained words "afn" is in sorted format for fan. File data faty gafny gaifny dafan gafnniunt O/p gafny gafnniunt (3 Replies)
Discussion started by: polineni
3 Replies

7. Linux

string characters in UNIX

I need some help. when i use the following command, it deletes all lines containing WINNT& v2010 and WINNT& v2010.2 I just want it to delete lines containing WINNT & v2010 only. perl -n -i.bak -e 'print unless /WINNT/&&/v2010/' *.* Danish (2 Replies)
Discussion started by: sdanish110
2 Replies

8. 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

9. UNIX for Dummies Questions & Answers

splitting a string in unix

i need to split a line using a delimiter, and store it into a array :( (2 Replies)
Discussion started by: lmadhuri
2 Replies

10. 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

Featured Tech Videos