Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Read the line from the last and display the one which is non-zero Post 302935498 by hariniiyer300 on Tuesday 17th of February 2015 06:10:48 AM
Old 02-17-2015
Read the line from the last and display the one which is non-zero

Hi All,

My requirement is this. Am trying to find a one liner unix command, which will check the last line of the file for 0. If it is zero, it would pick the previous line, else it should display the last line.

Eg:
Code:
abcd
efgh
ijhk
0
0

Output expected -- ijhk

Please share your ideas.

Thanks.

Last edited by rbatte1; 02-17-2015 at 08:50 AM.. Reason: Added CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read variable with no display

I'll be reading user name and password from the person while running a shell script so that he is authenticated. The challenge here is to read the password variable without displaying on screen. Is there a way? I presently do it displaying it on the screen as echo " please enter your... (9 Replies)
Discussion started by: dayanandra
9 Replies

2. Shell Programming and Scripting

Display mutiple line in single line

Hi All, I had a file called Input.txt, i need to group up in a single line as 1=ttt and the no of lines may vary bewteen the 1=ttt cat Input.txt 1=ttt,2=xxxxxx, 3=4545 44545, 4=66667 7777, 5=77723 1=ttt, 2=xxxxxx, 3=34436 66 3545, 4=66666, 5=ffffff, 6=uuuuuuu 1=ttt, 2=xxxxxx,... (4 Replies)
Discussion started by: manosubsulo
4 Replies

3. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

4. Shell Programming and Scripting

Read File and Display The Count of a particular field

Hi Mates, I require help in the following: I have the following file snmp.txt Wed Mar 2 16:02:39 SGT 2011 Class : mmTrapBladeS origin : 10.0.0.0 hostname : 10.0.0.2 msg : IBM Blade Alert: Calendar Index : 10.0.0.2-IBMBLADE Fri Mar 4 07:10:54 SGT 2011 Class : mmTrapBladeS... (2 Replies)
Discussion started by: dbashyam
2 Replies

5. Emergency UNIX and Linux Support

Grab total page read from webalizer display in html

Hi, I need a way to grab the total combines since inception, total pages read from webalizer on my centos server or any other location (as long as since inception) and display the result live on my website So with each visit it would be increasing, or perhaps live (ajax) not sure But can... (0 Replies)
Discussion started by: lawstudent
0 Replies

6. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

7. Shell Programming and Scripting

a little help with using AWK to display whats being read in

I am making a script that reads in the model of a car and then searches a file and displays the make model and price of anything matching the input provided. here is what I have so far #!/bin/sh echo Please enter a car model: read model if test $? -eq 0 then grep $model /home/cars awk... (4 Replies)
Discussion started by: subway69
4 Replies

8. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

9. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

10. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies
STATE_ANALYZER(8)					       AFS Command Reference						 STATE_ANALYZER(8)

NAME
state_analyzer - Explores and queries the fileserver state database interactively SYNOPSIS
state_analyzer [state dump file | -h] DESCRIPTION
The demand-attach file server makes host / callback information persistent. On shutdown, the state is saved to database fsstate.dat(5). On startup, the state is read, verified and restored. This allows for file server shutdowns or restarts without breaking all callbacks (an operation that could otherwise take a long time). state_analyzer interactively explores and queries the saved state database, fsstate.dat(5). This command is only supported on the demand-attach file server. It operates at an extremely low-level and hence requires detailed knowledge of the OpenAFS architecture and code. COMMANDS
state_analyzer supports the following interactive commands: h <...> -- host menu o hdr -- display the host_state_header struct o first -- display the first host o prev -- display the previous host o this -- display this host o next -- display the next host o last -- display the last host o dump -- display all hosts fe <...> -- FileEntry menu o hdr -- display the callback_state_header struct o first -- display the first FE o prev -- display the previous FE o this -- display this FE o next -- display the next FE o last -- display the last FE o dump -- display all FEs o timeout -- display the timeout queue heads o hash -- display the file entry hash buckets o find by index id -- find an fe by its array index o find by fid (vol,vnode,unique) -- find an fe by its AFSFid cb <...> -- CallBack menu o hdr -- display the callback_state_entry_header struct o first -- display the first CB o prev -- display the previous CB o this -- display this CB o next -- display the next CB o last -- display the last CB o dump -- display all CBs hexdump [offset [len]] -- hex dump raw data quit -- quit current menu exit -- exit debugger help -- help message PRIVILEGE REQUIRED
The issuer must have read access to the file server state database, fsstate.dat. Usually, this means that the issuer must be the local superuser "root" on the file server machine. SEE ALSO
fsstate.dat(5), fssync-debug(8), salvsync-debug(8) COPYRIGHT
Copyright 2010 Davor Ocelic <docelic@spinlocksolutions.com> This documentation is covered by the IBM Public License Version 1.0. This man page was written by Davor Ocelic for OpenAFS, based on documentation from Tom Keiser, Steven Jenkins and others. OpenAFS 2012-03-26 STATE_ANALYZER(8)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy