Sponsored Content
Top Forums Shell Programming and Scripting Help identifying the first word in a string Post 302478793 by malcomex999 on Thursday 9th of December 2010 01:38:25 AM
Old 12-09-2010
Code:
 
echo "enter your name"
read name
name=$(echo $name | cut -d" " -f1)
echo "hello $name"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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 (3 Replies)
Discussion started by: GMMike
3 Replies

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

3. Shell Programming and Scripting

Identifying a string from a set of files and printing to a new file

Dear All, I'm an amateur to writing scripts and need to do the following Need to read all files with a .log extension in a directory and identify the value for username i.e. all files have something like username = John. Once this is read, I need to print this value to a new file. The new file... (2 Replies)
Discussion started by: Kelly_B
2 Replies

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

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

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

7. Shell Programming and Scripting

Identifying entries based on 2 fields in a string.

Hi Guys, I’m struggling to use two fields to do a duplicate/ unique by output. I want to look IP addresses assigned to more than one account during a given period in the logs. So duplicate IP and account > 1 then print all the logs for that IP. I have been Using AWK (just as its installed... (3 Replies)
Discussion started by: wabbit02
3 Replies

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

9. Shell Programming and Scripting

Deleting a word from a string

Hello All, I have a string like below - /LDCA20/rel/prod/libina.a I want to delete "libina.a" which is at the end.How can I do this ?? Thanks in advance Regards, Anand (10 Replies)
Discussion started by: anand.shah
10 Replies

10. 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
look(1) 						      General Commands Manual							   look(1)

NAME
look - Finds lines in a sorted list SYNOPSIS
look [-df] [-tcharacter] string [file] The look command prints all lines in a sorted file that begin with string. OPTIONS
Uses dictionary order; only letters, digits, tabs, and spaces are used in comparisons. Searches without regard to case; treats uppercase and lowercase as equivalent. Ignores character and characters following it in the search string. If you specify look -tC ABCDE, the string ABCDE would become (in effect) AB, with CDE being ignored. This option is primarily for shell scripts, in which more than one string is being processed. DESCRIPTION
If no file is specified, look searches in the system word list /usr/share/dict/words, with the options -df assumed by default. The look command uses binary search. The -d and -f options affect comparisons as in sort. NOTES
In order to use the -f option, you must first sort file with the sort -f command; otherwise, look displays only lowercase items. If you do not specify -f, but specify a file (such as /usr/share/dict/words) that has been sorted with sort -f, look may not produce any output. EXAMPLES
To search a sorted file called sortfile for all lines that begin with the string as, enter: look as sortfile To search the system word list for all words beginning with smi, enter: look smi This might result in: smile smirk smith smithereens Smithfield Smithson smithy smitten FILES
System word list. SEE ALSO
Commands: grep(1), sort(1), spell(1) look(1)
All times are GMT -4. The time now is 03:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy