Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Take the 2nd line from the bottom Post 302761153 by Pieter0815 on Friday 25th of January 2013 08:31:38 AM
Old 01-25-2013
Take the 2nd line from the bottom

Dear friendly helpers,

I want to compare the last line and the 2.nd line from the bottom later with a calculation. The rest of the script is working. What is wrong with my solution?

I want to take the 2nd line from the bottom. And I do not know the command.
TAIL -2 is wrong because it takes the 2 bottom lines.
So I tried to take the 2 lines from the bottom with tail -2 and later the 1. line with head -1.


Code:
SIZE_SCR=`grep ^scr /rsi/logs/csc_summary_size_check.log | tail -1 | cut -d";" -f4 | cut -b1-3`
SIZE_VORHER_SCR=`grep ^scr /rsi/logs/csc_summary_size_check.log | tail -2 | cut -d";" -f4 | cut -b1-3 | head -1`

Thank you for helping.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the line count from 2nd line of the file ?

Hi, I want to get the line count of the file from the 2nd line of the file ? The first line is header so want to skip that. Thanks. (8 Replies)
Discussion started by: smc3
8 Replies

2. Shell Programming and Scripting

Get the bottom line of a file to the top of the file

Hi, i have a small requirement where i have to get the bottom most line from a file to the topmost position. a small example is shown below.. $ cat beep.txt It is first documented as being played in southern England. In the 16th century. By the end of the 18th century, Cricket is a... (5 Replies)
Discussion started by: Shellslave
5 Replies

3. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

4. UNIX for Dummies Questions & Answers

Help with editing 2nd line after match

Hi All I would like to break down each next line that matches SK1.chr* in this case NNNNNN.... into 100 characters each after SK1.chr*... (3 Replies)
Discussion started by: pawannoel
3 Replies

5. Shell Programming and Scripting

Search for string and print top and bottom line

Hi Folks I need a one liner to parse through a log and if the string is found print the line above, the line with the string and the line below. example: The ball is green and blue Billy through the ball higer. Jane got hurt with the ball. So if I search for Billy I would need the 3... (1 Reply)
Discussion started by: bombcan
1 Replies

6. Shell Programming and Scripting

1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format: 1st line,2nd line 3rd line,4th line 5th line,6th line ... Thanks! (6 Replies)
Discussion started by: batcho
6 Replies

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

8. UNIX for Beginners Questions & Answers

How to get 2nd last column of the line- UNIX?

I want to retrieve Status from below example. Columns numbers will be dynamic but Status will always be 2nd last- JobName StartTime EndTime Status ExitCode autorep -j $jobName | grep '^FR' | awk -F' ' '{print $2}' The above code gives me the 2nd column from start of the line. (7 Replies)
Discussion started by: Tanu
7 Replies

9. Shell Programming and Scripting

How do we display specific row of an output from bottom given line number?

I pass a number to my script. Passing "1" below. ./getfile.sh 1 echo "User entered: $1" ls -ltr *.conf | sed -n '$p' I wish to use ls -ltr i.e list files in ascending order of time the latest showing at the bottom of the output. Number 1 should get me the last row of ls -ltr output i.e... (9 Replies)
Discussion started by: mohtashims
9 Replies
TAIL(1) 						      General Commands Manual							   TAIL(1)

NAME
tail - deliver the last part of a file SYNOPSIS
tail [ +-number[lbc][rf] ] [ file ] tail [ -fr ] [ -n nlines ] [ -c ncharacters ] [ file ] DESCRIPTION
Tail copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is copied. Copying begins at position +number measured from the beginning, or -number from the end of the input. Number is counted in lines, 1K blocks or characters, according to the appended flag or Default is -10l (ten ell). The further flag causes tail to print lines from the end of the file in reverse order; (follow) causes tail, after printing to the end, to keep watch and print further data as it appears. The second syntax is that promulgated by POSIX, where the numbers rather than the options are signed. EXAMPLES
tail file Print the last 10 lines of a file. tail +0f file Print a file, and continue to watch data accumulate as it grows. sed 10q file Print the first 10 lines of a file. SOURCE
/sys/src/cmd/tail.c BUGS
Tails relative to the end of the file are treasured up in a buffer, and thus are limited in length. According to custom, option +number counts lines from 1, and counts blocks and characters from 0. TAIL(1)
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy