Sponsored Content
Top Forums UNIX for Dummies Questions & Answers extract last word on line to new file Post 20900 by auswipe on Tuesday 7th of May 2002 11:26:46 AM
Old 05-07-2002
In the spirit of "There is more than one way to do it" here is the a Perl sample for the same results...

Code:
#!/usr/bin/perl

while ($inputLine = <>) {
  my @values = split(/ /, $inputLine);
  print "$values[$#values]";
};

Sample in use:

Code:
OpenBSD:joeuser:/home/joeuser/sample $ lastword.pl < source.txt
Bullock
Avent
RUSSELL
Harris
Tyndall

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies

2. UNIX for Dummies Questions & Answers

Word extract from a line

In a file let a.txt, has 1 line code i.e. code QC:Tiger:10: /code I need to get my output like "Tiger 10". So how can i do this? (3 Replies)
Discussion started by: anupdas
3 Replies

3. Shell Programming and Scripting

How to extract just a word from a File in Shell?

Hello Friends, I have a txt file which has data like this TNS Ping Utility for Solaris: Version 10.2.0.3.0 - Production on 23-MAR-2010 15:38:42 Copyright (c) 1997, 2006, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to... (7 Replies)
Discussion started by: njafri
7 Replies

4. Shell Programming and Scripting

get the fifth line of a text file into a shell script and trim the line to extract a WORD

FOLKS , i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one. thanks... Venu (3 Replies)
Discussion started by: venu
3 Replies

5. Shell Programming and Scripting

Extract word from a line

Hi, I've searched the forum to get what I wanted but to no avail. Here's the problem I'm facing. The line is suppose as below: <INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS"> Now I want to extract only FACT_TABLE. The trials are as follows: awk... (3 Replies)
Discussion started by: dips_ag
3 Replies

6. UNIX for Dummies Questions & Answers

Need to extract the 2nd last word of each line

Hello experts, I have question that i want to extract the second last word of each line. I have a text file, in that text file there are near about 40 lines. sample of line present in file /user/Oracle/x/x/S/part_bkp/temp_part_bkp/x1/test1... (2 Replies)
Discussion started by: aks_1902
2 Replies

7. Shell Programming and Scripting

extract a word from text file name

Hi i want to extract the word present before .txt in the text file. For example, Sample_ab_a.txt ----------> i need 'a' Sample_abc_b.txt -----------> i need 'b' Can anyone help me in getting the word extracted (5 Replies)
Discussion started by: Sindhuap
5 Replies

8. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

9. Shell Programming and Scripting

Extract the word from the file and print it

I have a file which I am reading and then I need to extract a particualr word and if it matches the line. 2015-01-22 07:30:17,814000 +0900 /INFO: - <ns2:virtualServerid="PH11PK" /> Means if the line contain Virtual server I need to extract the id . Code I wrote#!/usr/bin/perl ... (19 Replies)
Discussion started by: karan8810
19 Replies

10. Shell Programming and Scripting

Need to extract the word after a particular keyword throughout the file..

Hi Everyone, Need help in extracting the hostname from the below output. Expected output: DS-TESTB-GDS-1.TEST.ABC.COM DS-TESTB-GDS-2.TEST.ABC.COM .... ... /tmp $ cat -n /tmp/patchreport 1 /usr/bin/perl /admin/bin/patch/applyPatches.pl --apply_patches... (4 Replies)
Discussion started by: thiyagoo
4 Replies
sasl_server_step(10 July 2001)											    sasl_server_step(10 July 2001)

NAME
sasl_server_step - Perform a step in the authentication negotiation SYNOPSIS
#include <sasl/sasl.h> int sasl_server_step(sasl_conn_t *conn, const char *clientin, unsigned clientinlen, const char ** serverout, unsigned * serveroutlen); DESCRIPTION
sasl_server_step() performs a step in the authentication negotiation. It returns SASL_OK if the whole negotiation is sucessful and SASL_CONTINUE if this step is ok but at least one more step is needed. conn is the SASL connection context clientin is the data given by the client (decoded if the protocol encodes requests sent over the wire) clientinlen is the length of cli- entin serverout and serveroutlen are set by the library and should be sent to the client. RETURN VALUE
sasl_server_step returns an integer which corresponds to one of the SASL error codes. SASL_CONTINUE indicates sucess and that there are more steps needed in the authentication. SASL_OK indicates that the authentication is complete. All other return codes indicate errors and should either be handled or the authentication session should be quit. CONFORMING TO
RFC 2222 SEE ALSO
sasl(3), sasl_errors(3), sasl_server_init(3), sasl_server_new(3), sasl_server_start(3) SASL man pages SASL sasl_server_step(10 July 2001)
All times are GMT -4. The time now is 08:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy