Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to separate First,Middle and Last Name from Full name Post 302549059 by shipra_31 on Sunday 21st of August 2011 05:24:35 AM
Old 08-21-2011
see if this work for all set of input ...for me it worked on the ones u gave

Code:
 
$ cat test.txt
Ashok Kumar
Ashok A K Kumar
Ashok K KUMAR
$


Code:
 
$ cat ./script.ksh
while read first i
do
last=`echo $i | /usr/bin/awk '{print $NF}'`
middle=`echo $i | /usr/bin/awk '{NF=NF -1; $1=$1 ; print}'`
echo "First name : $first"
echo "Middle name : $middle"
echo "Last name : $last"
done <test.txt
$



Output

$ ./script.ksh
First name : Ashok
Middle name : Kumar
Last name : Kumar
First name : Ashok
Middle name : A K
Last name : Kumar
First name : Ashok
Middle name : K
Last name : KUMAR
$
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Selecting the middle date!

Hi everyone really need some help with this one. Ive to write a script where the middle date has to be checked and made sure that it is the current date. 281220032812200328122003 This is the format ive to check the date in the middle is the current date. Can anyone help me with this... (14 Replies)
Discussion started by: vcardo10
14 Replies

2. Shell Programming and Scripting

How to 'sed' the middle line?

Hi, If I have 90 lines and I want to print the 45th line, is there a quick sed command for this? thx. (7 Replies)
Discussion started by: g_jumpin
7 Replies

3. Shell Programming and Scripting

change RS in the middle

in AWK, how can I change the RS (record separator) in the middle of awk command. for example: gawk 'NR==FNR { key++;next }; RS="?"; $1 in key' file1 file2 in above, I put RS="?" in the middle to change the value of RS to "?" right after the file1 has been processed. when it begins to... (2 Replies)
Discussion started by: fredao
2 Replies

4. Shell Programming and Scripting

How to process from middle of a file?

Hi There. I have a file like this . a nnnn sds b ssss fdefd c sdfd dsfd sdfds ... ... Summary t1 t2 t3 t4 s1 s2 s3 s4 f1 f2 f3 f4 .. How to use awk to begin process this file from the line that contains "Summary"? Thanks! louis (12 Replies)
Discussion started by: javacore
12 Replies

5. Shell Programming and Scripting

add a word in the middle

I have a file where in I need to add gctunit1/gtdivcompebb1/ after the = sign for example: gtfix31/gctunit_gtdivcompebb1/csclkswcompbypassstepgnnnh = gctunit1/gtdivcompebb1/csclkswcompbypassstepgnnnh (3 Replies)
Discussion started by: pitagi
3 Replies

6. Shell Programming and Scripting

How to extract strings from full path when full path is not fixed

/Path/snowbird9/nrfCompMgrRave1230100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird6/nrfCompMgrRave1220100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird14/nrfCompMgrRave920100920.log.gz:09/20/2010 06:14:51 ERROR Error Message.... (0 Replies)
Discussion started by: Shirisha
0 Replies

7. Shell Programming and Scripting

Adding new column in the middle

Hi , I need to add few new columns in existing file .Any help would be great ex: existing file name,typ,add,dept New file(com1,sal are new) name,com1,type,sal,add,dept Thanks, mohan (1 Reply)
Discussion started by: mohan705
1 Replies

8. AIX

100% Inode full with only 67% FS full.

AIX Version 6.1 and 7.1. I understand that when the OS initially creates the FS and inodes, its pretty strict, but not always tuned to a 1:1 ratio. I see the same thing when adding a whole disk LV to a separate device. It seems that when we expand a filesystem the inodes don't get tuned... (5 Replies)
Discussion started by: mrmurdock
5 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 02:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy