Sponsored Content
Top Forums Shell Programming and Scripting current line number in shell script Post 302399244 by xiamin on Friday 26th of February 2010 08:30:55 PM
Old 02-26-2010
current line number in shell script

Hi

I am using korn shell is there a built in or ny other way to get the current line number so i can write the current line number to the logfile to aid in debugging like


logmsg $lineno $date

logmsg is a helper function that helps in logging messages to a log file

regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i execute script in the current shell

How do i run a shell script or perl script with in the context of a current shell. I know that i can use command source. but we can't pass any arguments to our script if we use source command as it takes only one argement i.e filename Is there any way to run a script in the current shell... (5 Replies)
Discussion started by: Naresh Kumar
5 Replies

2. Shell Programming and Scripting

Trigger Shell Script from Current Script

Hello all, I'm new to shell programming and need some help. I would like to set up a step within a shell script to trigger another shell script to run, based on the highest return code generated in the current script. For example, if the highes return code value in the current script is less... (1 Reply)
Discussion started by: mmignot
1 Replies

3. Shell Programming and Scripting

how do i get current bandwidth usage via shell script?

hello unix-people. can u please tell me how i can get the current bandwidth usage of my machine on shell into variables? thanks a lot (2 Replies)
Discussion started by: scarfake
2 Replies

4. Shell Programming and Scripting

Shell Script to identify the line number containing a particular "string"

Hi, I have a log file, where i am required to identify the line number, where a particular string/line appears in the log file. And then copy 200 lines above that line number to a new file. Can someone provide pointers on how to write this script or what command to be used ? Any... (2 Replies)
Discussion started by: kk2202
2 Replies

5. Shell Programming and Scripting

Shell script to count number of ~ from each line and compare with next line

Hi, I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each... (3 Replies)
Discussion started by: Ganesh Khandare
3 Replies

6. Shell Programming and Scripting

Substracting days from current date(K shell script)

Hi, I want to subtract 'n' days from the current timestamp in a k shell script. Is there any inbuilt function to do it or any workaround solution to get the date. And I want the output to be in YYYY:MM:DD HH:MM:SS format. Please help. Thanks in advance. (4 Replies)
Discussion started by: Suryaaravindh
4 Replies

7. Shell Programming and Scripting

How to read from specific line number in shell script?

I have a text file which is having 30000 lines in it. I have to create a xml file for each 10000 lines until all the lines in the text files are written. Also please help how can i get number of lines in the text file in a shell variable? (19 Replies)
Discussion started by: vel4ever
19 Replies

8. Shell Programming and Scripting

sed script- current and next line

Hi I have been using sed -n -e '/regex/{N;p;}' to print the matching line and the next line. In cases where I have a matching line at the end of the document with no next line, that line is skipped. How do I print that line as well? Thanks. (10 Replies)
Discussion started by: jamie_123
10 Replies

9. Shell Programming and Scripting

Detect current shell inside a script

I wish to print my current shell which happens to be bash in my script check.sh more check.sh echo $0 echo `ps -p $$` But instead of printing it prints check.sh i.e the name of the script for both the commands. Can you please suggest how to print the current shell i m on inside the... (2 Replies)
Discussion started by: mohtashims
2 Replies

10. Shell Programming and Scripting

Get the line number in shell script

I have one text file 1 2 3 a 5 4 4 3 where i want to print the line number while read line do line_no=`awk '{print NR, $0}'` echo 'In line no $line_no' done <$txt_file If i run the above code, it will print 'In line no 1 1 2 3' It prints the line number with the whole... (3 Replies)
Discussion started by: RJG
3 Replies
CLOGIT(3)						     Common Library Functions							 CLOGIT(3)

NAME
Clogit - log server messages in local log or in system logger SYNOPSIS
#include "Clog.h" int Cinitlog (char *cmd, char *logfile) int Clogit (int level, char *func, char *msg, ...) int Cvlogit (int level, char *func, char *msg, va_list ap) DESCRIPTION
Cinitlog initializes the server logging routines. Clogit logs server messages in a local log or in the system logger. Cvlogit is the same as Clogit but takes a va_list instead of a variable number of arguments. cmd specifies a string to be prepended to the syslog messages. logfile specifies a path for the server log file. If set to syslog, the system logger will be used. By default, only messages with level at least as important as LOG_INFO will be logged. The level threshold can be changed with the environment variable LOG_PRIORITY. level is associated with the message. The possible values, in order of decreasing importance are: LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR LOG_WARNING LOG_NOTICE LOG_INFO LOG_DEBUG func is the name of the function that issues the message. msg is a format as in printf. RETURN VALUE
These routines return 0 if the operation was successful or -1 if the operation failed. In the latter case, serrno is set appropriately. ERRORS
EFAULT logfile is a NULL pointer. ENAMETOOLONG The length of logfile exceeds CA_MAXPATHLEN. LCG
$Date$ CLOGIT(3)
All times are GMT -4. The time now is 08:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy