Sponsored Content
Full Discussion: printing a line of a file
Top Forums UNIX for Dummies Questions & Answers printing a line of a file Post 562 by clay on Thursday 14th of December 2000 04:42:44 PM
Old 12-14-2000
Data printing a line from a file

I think that the former thread is not correct.
What I am trying to do is when the script is triggered by
an ip address, it goes to a file called ipconnect.txt and
print the row that has the corresponding ip address in it.
The data in ipconnect is a list of ip address followed by a
tab and then the owner's ip address.
This is the entire script and I think that the netstat is
what need to be looked at.

export HOUR=`/usr/bin/date +%H`
export MINUTE=`/usr/bin/date +%M`
export REMOTECOUNT=`ps -ef | grep LOCAL=NO | wc -l`;
if [ $REMOTECOUNT -ne 1 ]
then
export REMOTER=`expr ${REMOTECOUNT} - 1`
print $REMOTER "=REMOTE CONNECTIONS" > /cron/test_listen_out;
netstat -an | grep "50.1521" | cut -c22-42 | egrep -v /cron/stars >> /cron/test_listen_out;
export DAVIDCOUNT=`fgrep -ce 140.147.146.146 /ipconnect.txt`;
fgrep 140.147.146.146 >> /cron/test_listen_out;
if [ $DAVIDCOUNT -ne 0 ]
then
print "David Williamson" >> /cron/test_listen_out;
fi
...
fi
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printing an empty line in a file (perl)

I know this must be really easy, but i can't get it to work I've got a perl script, with a file. I want to print an empty line, and the following doesn't seem to work: print nameoffile "\n" thanks for your help!! (3 Replies)
Discussion started by: kfad
3 Replies

2. UNIX for Dummies Questions & Answers

Printing a Line from a file

I have a log file with several lines as follows: Aug 30 06:35:08 trnwvltfit1 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping I am using the date of the line to determine which lines to print. However, I am only trying to print the parts of the line that are NOT... (4 Replies)
Discussion started by: Nysif Steve
4 Replies

3. Shell Programming and Scripting

Re-write first line of a file before printing

Morning All, Quite a simple one this, I hope. What I want to do is to re-write the first line of a file before it's sent to print. The line will be blank initially, and I want to insert some text. The operation can either be done on the file itself (modifying the file on disk), OR in a... (2 Replies)
Discussion started by: alexop
2 Replies

4. UNIX for Advanced & Expert Users

printing specific line from a file.

The below line gives the perfect output when I mention the record number and file name as hardcoded. awk 'NR==3{print}' samp2.txt But when I pass the record num and file name as variable, it doesn't give any output. row_num=3;file2=samp2.txt;awk 'NR==$row_num {print}' $file2 Can you... (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

5. Shell Programming and Scripting

printing each line in a file X times

This is probably simple but I would like to print every line in a file 5 times like this: awk 'NR' mens_csv.tab Dub Tank 53%Hemp/42%Cotton/5%Lycra Jersey Dark Green 0 $22.50 Dub Tank 53%Hemp/42%Cotton/5%Lycra Jersey Indigo Blue 0 $22.50 --------------- Dub... (4 Replies)
Discussion started by: Autumn Tree
4 Replies

6. Shell Programming and Scripting

Printing a particular line to a file

Hi, I have a file in which the entries are of the following type: 5649 S 1 0412 S 0 0423 S 1 0020 N 0 0020 N 0 1022 S 1 1022 S 1 I need to print the whole line which is having 0 in the third column into a different file Thanks... (6 Replies)
Discussion started by: swasid
6 Replies

7. UNIX and Linux Applications

Printing a line in a file

Hi I have a file having multiple lines. I want to print a particular line. How can I do this? Thanks in advance Ananth (5 Replies)
Discussion started by: Ananthdoss
5 Replies

8. Homework & Coursework Questions

Lex: analyzing a C file and printing out identifiers and line numbers they're found on

Florida State University, Tallahassee, FL USA, Dr. Whalley, COP4342 1. The problem statement, all variables and given/known data: Create a lex specification file that reads a C source program that ignores keywords and collects all identifiers (regular variable names) and also displays the line... (3 Replies)
Discussion started by: D2K
3 Replies

9. Shell Programming and Scripting

Awk: Comparing arguments with in line values of file and printing the result

I need to develop a script where I will take two date arguments as parameter date1 and date2 which will in format YYYYMM. Below is the input file say sample.txt. sample.txt will have certain blocks starting with P1. Each block will have a value 118,1:TIMESTAMP. I need to compare the... (7 Replies)
Discussion started by: garvit184
7 Replies

10. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
CRONTAB(1)						    BSD General Commands Manual 						CRONTAB(1)

NAME
crontab -- maintain crontab files for individual users (V3) SYNOPSIS
crontab [-u user] file crontab [-u user] { -l | -r | -e } DESCRIPTION
The crontab utility is the program used to install, deinstall or list the tables used to drive the cron(8) daemon in Vixie Cron. Each user can have their own crontab, and they are not intended to be edited directly. (Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.) If the /usr/lib/cron/cron.allow file exists, then you must be listed therein in order to be allowed to use this command. If the /usr/lib/cron/cron.allow file does not exist but the /usr/lib/cron/cron.deny file does exist, then you must not be listed in the /usr/lib/cron/cron.deny file in order to use this command. If neither of these files exists, then depending on site-dependent configuration parameters, only the super user will be allowed to use this command, or all users will be able to use this command. The format of these files is one username per line, with no leading or trailing whitespace. Lines of other formats will be ignored, and so can be used for com- ments. The first form of this command is used to install a new crontab from some named file or standard input if the pseudo-filename '-' is given. The following options are available: -u Specify the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines ``your'' crontab, i.e., the crontab of the person executing the command. Note that su(1) can confuse crontab and that if you are running inside of su(1) you should always use the -u option for safety's sake. -l Display the current crontab on standard output. -r Remove the current crontab. -e Edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. The specified editor must edit the file in place; any editor that unlinks the file and recreates it cannot be used. After you exit from the editor, the modified crontab will be installed automatically. FILES
/usr/lib/cron/cron.allow /usr/lib/cron/cron.deny DIAGNOSTICS
A fairly informative usage message appears if you run it with a bad command line. SEE ALSO
crontab(5), compat(5), cron(8), launchctl(1) STANDARDS
The crontab command conforms to IEEE Std 1003.2 (``POSIX.2''). The new command syntax differs from previous versions of Vixie Cron, as well as from the classic SVR3 syntax. AUTHORS
Paul Vixie <paul@vix.com> BSD
December 29, 1993 BSD
All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy