Sponsored Content
Top Forums Shell Programming and Scripting Howto return the single penultimate line from my output Post 302345536 by kingpin2502 on Wednesday 19th of August 2009 01:25:57 PM
Old 08-19-2009
Howto return the single penultimate line from my output

Hi All

I have what seems to be something quite trivial but for the life of me can't work out a solution.

Basically, I have the following script that reads a version report that contains certain flags. If a condition is true, I want to print the value of column 2, sort them uniquely and return the penultimate line from that file.

This is a sample of the input

Code:
MR,dynamic.20090811.0554,TRUE,FALSE,TRUE
MR,dynamic.20090817.0734,TRUE,FALSE,TRUE
MR,dynamic.20090818.0808,TRUE,FALSE,TRUE
MR,dynamic.20090818.0808,TRUE,FALSE,TRUE

I can do everything except return the second line. This is sample of the script I am using. I redirect my output from the read statement into a temporary file, sort that file and then from there I want to return the row i want. I'm not sure if is the most efficient but .

Code:
while read event; do

is_ph_true=`echo $event | cut -f5 -d,`

        if [ $is_ph_true = "TRUE" ]; then
                `echo $event | cut -f2 -d, >> tmp`
        fi
done<versions.report

                sort -u tmp

This is where I'm stuck. Any help as usual will be appreciated.

tia.

Last edited by vgersh99; 08-19-2009 at 02:38 PM.. Reason: code tags, PLEASE!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multi-line output to single line

Hello, How can I take the following output: outputa outputb outputc and turn it into single line ouput, with a single space between each field like below: outputa outputb outputc (7 Replies)
Discussion started by: LinuxRacr
7 Replies

2. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

3. Shell Programming and Scripting

Output coming in different line instead of single line

Hi Guys, I have an oracle database, I am trying to query the database and route it to file. But the records instead of coming in a single line, are coming in three lines. Can you please help me.. in this.. sqlplus -s $SRMUserid/$SRMPassword@$SRMServer<< EOF >log.out; select * from... (5 Replies)
Discussion started by: mac4rfree
5 Replies

4. Shell Programming and Scripting

howto place in one line output from two functions

Hi I would like to place in one line output from two functions. Both functions return text with print cmd. When I place above code in script it will place them in series. e.g. 1 #/bin/ksh 2 3 function1() 4 { 5 print "My name is" 6 ... (3 Replies)
Discussion started by: presul
3 Replies

5. Shell Programming and Scripting

Output to be in single line

Hi All, Small script but :wall:, please help in this regard. for i in 1 2 3 do echo $i done result : 1 2 3 I want the above to be printed as below expected result: 1 2 3 Thanks in advance :) (3 Replies)
Discussion started by: girish_satyam
3 Replies

6. Shell Programming and Scripting

Merge multi-line output into a single line

Hello I did do a search and the past threads doesn't really solve my issue. (using various awk commands) I need to combine the output from java -version into 1 line, but I am having difficulties. When you exec java -version, you get: java version "1.5.0_06" Java(TM) 2 Runtime... (5 Replies)
Discussion started by: flagman5
5 Replies

7. Shell Programming and Scripting

useless line feeds in ldapsearch output. Howto remove with shell script?

Hi $ cat ad.sh ldapsearorg -x -LLL -h sb1131z.testbadbigcorp.org -D "CN=ADMINZZ,OU=AdminRoles,DC=testbadbigcorp,DC=org" -w "UT3w4f57lll--4...4" -b "OU=Test,DC=testbadbigcorp,DC=org" "(&(&(&(&(objectCategory=person)(objectClass=user)(lockoutTime:1.2.840.113556.1.4.804:=4294967295)))))" dn$... (3 Replies)
Discussion started by: slashdotweenie
3 Replies

8. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

9. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips 10.26.208.28 10.26.208.26 10.26.208.27 want to convert above single line output as below format. Pls advice how to do ? 10.26.208.28 10.26.208.26 10.26.208.27 Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

10. UNIX for Beginners Questions & Answers

Output to file print as single line, not separate line

example of problem: when I echo "$e" >> /home/cogiz/file.txt result prints to file as:AA BB CC I need it to save to file as this:AA BB CC I know it's probably something really simple but any help would be greatly appreciated. Thank You. Cogiz (7 Replies)
Discussion started by: cogiz
7 Replies
AUTOFS.CONF(5)						      BSD File Formats Manual						    AUTOFS.CONF(5)

NAME
autofs.conf -- automount(8) and automountd(8) configuration file DESCRIPTION
The autofs.conf file specifies various configuration options for automount(8) and automountd(8). autofs.conf consists of a series of lines, each of which may contain a line that sets a parameter, a comment, or a blank line. A line that sets a parameter has the format: parameter=value A ``#'' is the comment character, and all characters from it to the end of line are ignored. The parameters that are supported are: AUTOMOUNT_TIMEOUT The number of seconds after which an automounted file system will be unmounted if it hasn't been referred to within that period of time. The default is 10 minutes (600 seconds). This is equivalent to the -t option in automount(8). AUTOMOUNT_VERBOSE TRUE or FALSE; if TRUE, automount(8) will print more detailed information about the actions it takes. This is equivalent to the -v option to automount(8). AUTOMOUNTD_VERBOSE TRUE or FALSE; if TRUE, automountd(8) will log to syslogd(8) more detailed information about the actions it takes. This is equivalent to the -v option to automountd(8). AUTOMOUNTD_NOBROWSE TRUE or FALSE; if TRUE, automountd(8) will disable browsing of all maps. This is equivalent to the -n option to automountd(8). AUTOMOUNTD_TRACE The trace level for logging information about requests received by automountd(8) from autofs, processing done for those requests, and replies sent to autofs. The default level of 0 causes no information to be logged; each higher value causes more information to be logged. This controls the same trace level that the -T option to automountd(8) controls. The trace is logged to /var/log/system.log AUTOMOUNTD_MNTOPTS A string containing a comma-separated list of mount options that will be applied, by default, to all mounts done by automountd(8). The options for a particular mount can override these options. This controls the same options that the -o option to automountd(8) AUTOMOUNTD_NOSUID TRUE or FALSE; if TRUE, automountd(8) will force all mounts to have the "nosuid" mount option set. AUTOMOUNTD_ENV A string of the form name=value that causes the environment variable name to be set to the value value in automountd(8). Environment variables can be referred to in map entries; the value of the environment variable is substituted for the reference to the variable. This is equivalent to the -D option to automountd(8). FILES
/etc/autofs.conf This file. SEE ALSO
auto_master(5), automount(8), automountd(8) Darwin March 27, 2007 Darwin
All times are GMT -4. The time now is 12:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy