Sponsored Content
Full Discussion: tail, grep and cut
Top Forums Shell Programming and Scripting tail, grep and cut Post 302172293 by joeyg on Monday 3rd of March 2008 09:44:16 AM
Old 03-03-2008
Question Confused about some of your syntax

What are you trying to accomplish with the tail -f command?
And then your grep "third"?

Are you simply trying to narrow your search to the last ten lines (default of the tail command), and then find the line with the word "third"? If so, try without the -f on the tail command.

By the way, I am not convinced that your example works fine when you think it does. The -f on the tail command would appear to keep the process running awaiting additional input.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with tail /grep needed

Hello: I'm a very newbee at UNIX/AIX. What i want to do is to tail a file from the bottom until a certain string is found and write all the lines after the found string to another file. I've tried out a lot of combination with tail and grep but doesn't find the good one. Could someone help... (4 Replies)
Discussion started by: Felix2511
4 Replies

2. Shell Programming and Scripting

tail | grep lagging badly

I'm trying to use tail/grep to monitor a log file. The command I cooked up is: tail -n 50 -f output.log | grep 'type:system' | cut -f 5- A sample line from the log file is: 1208894862 type:system session:0 severity:4 load started the columns are tab delimited. this works ok, except... (3 Replies)
Discussion started by: WasabiVengeance
3 Replies

3. Shell Programming and Scripting

Grep or Tail in shell script

Hi, I am writing a shell script that checks catalina logs on a production system and mails me if it detects errors. It greps the logs for known errors which i have defined as variables. The problem is the logs are huge, approx 30,000 before they rotate. So I am forced to use grep instead... (3 Replies)
Discussion started by: Moxy
3 Replies

4. Shell Programming and Scripting

tail | grep

The program that is running on my machine generates log files. I want to be able to know the number of lines that contain "FT" in the most recent log file. I wrote the following, but it always returns zero. And I know the count is not zero. Any ideas? ls -rt *.log | tail -n 1 | grep -c FT (6 Replies)
Discussion started by: sdilucca
6 Replies

5. Shell Programming and Scripting

Help with cut and tail

Hey!! I'm having a hard time getting this to work! I need to input a name and compare that name to a file in the file the name has a code on the same line as it, what i need is to compare the input name with the file and then output the code to a other file. Ex: ... (16 Replies)
Discussion started by: nogame11
16 Replies

6. UNIX for Dummies Questions & Answers

Need help with a tail and a grep

I need to tail -f a file so I can monitor it as it is being written to. However, there is a lot of garbage in the file that I don't care about. So normally I would just pipe and grep for the string that is important to me. However, in this case, there are two things I need to grep for. I can't... (3 Replies)
Discussion started by: Silver11
3 Replies

7. UNIX for Dummies Questions & Answers

mulitple grep using tail

I have a basic tail/grep question. I have logs that are generated & kept in a directory called alert_audit. I am using "tail" to see the logs that are coming in, but I only need logs that contain the IP address 10.249.185. or 10.247.231. Here is the command I have, but it pulls all IP... (3 Replies)
Discussion started by: robertson1995
3 Replies

8. Slackware

How should I cut this line using cut and grep?

not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell. but how must the command be? grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d the delimeter is just a space. can you help meplease. :D (1 Reply)
Discussion started by: garfish
1 Replies

9. UNIX for Dummies Questions & Answers

Tail -f | grep > output.txt

hi guys, I perform a sort of monitoring. I have a server running and with tail -f | grep "Searchstring"I monitor the log-file for recent specific entries. This is ok and works fine. Now, in addition I want to have my search results not posted into the shell but into a file. I tried: tail... (3 Replies)
Discussion started by: LaUs3r
3 Replies

10. Shell Programming and Scripting

Trouble with tail and grep

Good Morning, i ran into some trouble this morning while 'improving' my monitoring stuff. i would like to get a warning when the number of mails sent (outbound) by postfix is above a certain number. so far, so easy. to test that i simply put cat /var/log/mail.info | grep 'to=<' | grep -v -e... (1 Reply)
Discussion started by: Mike
1 Replies
tail(1) 						      General Commands Manual							   tail(1)

NAME
tail - Writes a file to standard output, beginning at a specified point SYNOPSIS
tail [-f | -r] [-c number | -n number] [file] tail [+number | -number] [unit] [-f | -r] [file] The tail command writes the named file (standard input by default) to standard output, beginning at a point you specify. The second synopsis form of this command is obsolete, and support may be withdrawn at any time. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: tail: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Displays the remainder of the file from the starting point number where number is measured in bytes. The sign of number affects the loca- tion in the file at which to begin the copying: Copying begins relative to the beginning of the file. Copying begins relative to the end of the file. Copying begins relative to the end of the file. The origin for counting is 1, that is, -c +1 represents the first byte of the file, -c -1 the last. Does not end after it copies the last line of the input file if the input file is not read from a pipe, but enters an endless loop in which it sleeps for a sec- ond and then attempts to read and copy further records from the input file. Thus, it can be used to monitor the growth of a file being written by another process. Has no effect if specified with -r. Displays remainder of file from the starting point number where number is measured in lines. The sign of number affects the location in the file, measured in lines, to begin the copying: Copying begins relative to the beginning of the file. Copying begins relative to the end of the file. Copying begins relative to the end of the file. The origin for counting is 1, that is, -n +1 represents the first line of the file, -n -1 the last. [Tru64 UNIX] Causes tail to print lines from the end of the file in reverse order. The default for -r is to print the entire file this way. Overrides -f. Begins reading number lines (l), 512-byte blocks (b), kilobyte blocks (k), characters (c and m) from the end of the input. The m argument counts mulktibyte characters as single-byte characters, while c counts characters byte-by-byte but does not break mulk- tibyte characters. The default unit is l for lines. The default number is 10 for all units. Begins reading number lines (l), 512-byte blocks (b), 1-kilobyte blocks (k), or characters (c and m) from the beginning of the input. The m argument counts mulktibyte characters as sin- gle-byte characters, while c counts characters byte-by-byte but does not break mulktibyte characters. The default unit is l for lines. The default number is 10 for all units. In the non-obsolescent form, if you do not specify either -c or n, -n 10 is the default. DESCRIPTION
If you do not specify -f, -r, -number, or +number, tail begins reading 10 lines before the end of the file. The default starting point is - (end of input), l (lines) is the default unit, and 10 is the default number. By specifying +, you can direct tail to read from the beginning of the file. By specifying a number or a unit, or both, you can change the point at which tail begins reading. [Tru64 UNIX] The unit argument can specify lines, blocks, or characters. The tail command can begin reading number (10 by default) units from either the end or the beginning of the file. [Tru64 UNIX] The block size is either 512 bytes or 1 kilobyte. NOTES
When the input is a text file containing mulktibyte characters, use the -c option cautiously since the output produced may not start on a character boundary. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To display the last 10 lines of a file named notes, enter: tail notes To specify how far from the end to start, enter: tail -20 notes This displays the last 20 lines of notes. To specify how far from the beginning to start, enter: tail +200c notes | more This displays notes a page at a time, starting with the 200th character from the beginning. To follow the growth of a file named accounts, enter: tail -1 -f accounts This displays the last line of accounts. Once every second, tail displays any lines that have been added to the file. This contin- ues until stopped by pressing the Interrupt key sequence. ENVIRONMENT VARIABLES
The following environment variables affect the execution of tail: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to mulktibyte characters in arguments and input files). Determines the locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: cat(1), head(1), more(1), page(1), pg(1) Standards: standards(5) tail(1)
All times are GMT -4. The time now is 09:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy