How to get the n-th word in a string


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to get the n-th word in a string
Prev   Next
# 1  
Old 09-07-2004
How to get the n-th word in a string

Hi,
Suppose I do this:

$ wc file.txt
96 333 6629 file.txt

and I want to get the 3rd word from the left (i.e. get the string 6629) and check its value.

What do I do?

Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove last word of a string?

Hello I have a string that may or may not have 4 dots. The string is actualy a file within a folder, where multiple files are located. Files may look like: # ls * creds: 192.168.10.110 someserver shares: 192.168.10.110.Public someserver.sharefolder # I want to fill 2 variables,... (1 Reply)
Discussion started by: sea
1 Replies

2. Shell Programming and Scripting

Print the word after the string

Hi I have a requirment here. I have to out the string after the particular word. for example i have the to extract the first word after the word disk. help me out. i have tried the folloing code but it is not giving the output which i need. awk -F"*disk " '{print $1}' grep -n -o '' file Input... (2 Replies)
Discussion started by: saaisiva
2 Replies

3. Shell Programming and Scripting

How can we get the character before and after a word in a string?

Hi friends, I am working in a korn shell. i want to know the command which gives me the previous one character and next one character of a given keyword in a string? for exmaple: input string: /bin/dir/folder1/.proc_name^folderone Keyword: proc_name output : .^ ... (10 Replies)
Discussion started by: neelmani
10 Replies

4. Shell Programming and Scripting

Replace a word in a string starting with another word

Hi All, I have a file in which a number of lines are starting with similar first word but different next words. I want to replace the any nth word(not 1st or 2nd) with another word. Eg:- My file contains are like this:- Ram is a boy. Ram is a good boy. Ram plays cricket. Here I want to... (2 Replies)
Discussion started by: mukeshbaranwal
2 Replies

5. Shell Programming and Scripting

Help: Need to Print a string from a word

Hi Folks Can you please help me to grep a word from below test file Below is the file looks like ABCD Test:3 ZZZZYYYZZ ABCD TEST:38 XXXYYYZZZ I need below output echo $A=21455 echo $B=3 and for second line echo $A=324494 echo $B=38 I will use While read line for each line.. i... (7 Replies)
Discussion started by: Machha
7 Replies

6. Shell Programming and Scripting

grep part of word or Another word from a string

Hi all, FileOne family balance >>>>> 0 0 0 0 java.io.FileNotFoundException: Settings.xml (No such file or directory) at java.io.FileInputStream.open(Native Method) .. .... ..... ..... java.lang.NullPointerException ... ..... ...... Stacktrace: at... (2 Replies)
Discussion started by: linuxadmin
2 Replies

7. Shell Programming and Scripting

Help identifying the first word in a string

Hi all, I'd like to know how to identify the first word in a string (in bash) for e.g. echo "enter your name" read name (user enters 'Joe Bloggs' for e.g.) echo "hello $name" (output says "hello Joe") Thanks for any help (5 Replies)
Discussion started by: kazazza
5 Replies

8. Shell Programming and Scripting

Replace a word After a string.

Hello Gurus, I have a file which has foll contents scattered: ,TotUnasgndNetAmt FROM DEV_EIS_T.Wkly_SO_CCD_MOSumSnpsht WHERE CalDayRunDt = '2010-07-21' UNION ALL SELECT CalDayRunDt ,BusWkCd ,'N' I want to replace 2010-07-21 that starts after ' and ends before... (8 Replies)
Discussion started by: indrajit_u
8 Replies

9. Shell Programming and Scripting

Replace a word from a string

How can i replace a particular word from string i.e. var="shiv_dutt_para_shar" wrd="para" rep_wrd="PARA" what i am trying to do that first i'll search if $var catains #wrd or not. if it contains then i've to replace $wrd with $rep_wrd. I have tried following #!/bin/sh t="shiv... (5 Replies)
Discussion started by: jadoo_c2
5 Replies

10. UNIX for Dummies Questions & Answers

How to get the location of word in a string

How to use instr function in awk ? to get the location a) for example instr('productiondata_12','data',1) to get the location of data using awk. b) for example instr('sampledata_rev_12','rev',1) to get the location of data and reaplce with "org" using awk. can anyone help ... (3 Replies)
Discussion started by: Vrgurav
3 Replies
Login or Register to Ask a Question
DXmGetLocaleString(3X)													    DXmGetLocaleString(3X)

NAME
DXmGetLocaleString - Provides locale-sensitive Motif compound string version of Toolkit ASCII default values. SYNOPSIS
XmString DXmGetLocaleString( I18nContext context, char *string, I18nWordType word_type ); PARAMETERS
Reserved for future use. (Null value passed.) Null-terminated string specifying the ASCII string value whose locale sensitive version is to be retrieved (for example, the string "OK"). Specifies the type (part of speech) of a word in the string, as indicated by one of the following values: ------------------------------------------ Value Description ------------------------------------------ I18NADJECTIVE The word is an adjective. I18NADVERB The word is an adverb. I18NNOUN The word is a noun. I18NVERB The word is a verb. ------------------------------------------ DESCRIPTION
The DXmGetLocaleString routine provides a locale-sensitive Motif compound string version of Toolkit ASCII default values, such as "OK" or "Cancel". You can specify the part of speech (adjective, adverb, verb, or noun) associated with each word in the string. RETURN VALUES
A pointer to the Motif compound string containing the value. DXmGetLocaleString(3X)