01-09-2020
Welcome to the forums!
A number of things is wrong (to start with):
1. a logical construct [ logical ] should have trailing/leading spaces, e.g.: if [ "$DAYOFWEEK" == 1 ]
2. numerical comparison within the [] should be done with -eq/-ge/-le/etc..., eg: if [ "$DAYOFWEEK" -eq 1 ]
3. the grouping of the logicals within the if, should be done as follows, e.g. if [ logical1 ] && [ logical2 ]
4. you're missing a 'closing' fi for your leading if - I bet your trailing doneshould be an fi
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a rather big script that i have written in ksh and it is falling over in two places with a 'test argument' error. I know this usually means that the if statement is not correct, but it is fine. I have looked through the rest of the script for any odd brackets or ` marks, but can't see... (2 Replies)
Discussion started by: handak9
2 Replies
2. Shell Programming and Scripting
How do I change directories to a path given by input variable in Korn Shell?
e.g. I tired with the Korn Shell below but it doesn't work.
----------------------------------
#!/bin/ksh
echo "Enter folder name: \c"
read folder
cd $folder
----------------------------------
Any help will... (5 Replies)
Discussion started by: stevefox
5 Replies
3. UNIX for Dummies Questions & Answers
Hello,
How do I write a korn shell that will rename file with the current date. What I want to do is, I have a file that is re-written every day. But instead, I want to keep a 14 day history of the file. So I want to write a script that will rename the current file with a date attached to the... (2 Replies)
Discussion started by: watson2000
2 Replies
4. Shell Programming and Scripting
How do I replace a space " " character at a particular position in a line?
e.g. I have a file below
$ cat i2
111 002 A a
33 0011 B c
2222 003 C a
I want all the 1st spaces to be replaced with forward slash "/" and the 3rd spaces to have 5 spaces to get the output below:
111/002... (8 Replies)
Discussion started by: stevefox
8 Replies
5. Shell Programming and Scripting
Hi all,
I need a Korn Shell script that will go out to all Unix Servers and pull all non humans IDs from them while at the same time produce a file to show which servers we have access to and which ones we don't.
Thanks in advance. (5 Replies)
Discussion started by: vinsara
5 Replies
6. Shell Programming and Scripting
I'd like a shell-script syntax checker that can detect at least the following errors, and more:
1. Variable $VAR used but VAR has not been defined.
2. Variable VAR defined but never used.
3. Use of unquoted variables which might break external commands e.g. SOMETHING in: value=`grep $SOMETHING... (5 Replies)
Discussion started by: garethr
5 Replies
7. Shell Programming and Scripting
Hi,
I am new to this unix scripting, I got a requirement like..
Files with *.XML extension will be generating in a /home/sample/ folder for every 15 mins. I need to monitor those files in that particular folder for every hour.
If no file has been generated in that particular folder for an... (7 Replies)
Discussion started by: siri_886
7 Replies
8. Shell Programming and Scripting
All,
Can anyone please help me with the below scenario in korn shell script.
Can anyone please give me some hints to proceed on this.
I have a Flat file of the below format.
Input file format:... (1 Reply)
Discussion started by: sp999
1 Replies
9. Shell Programming and Scripting
#! /bin/ksh
while read line
do
if ] ; then
echo "no data"
continue;
fi
echo "performing operation on $line"
done < prg.txt (3 Replies)
Discussion started by: Juhi Kashyap
3 Replies
10. Shell Programming and Scripting
Hi,
I have files in the directory like below which I need to validate if all the required files are present.
A_B_001 of 002_time1.txt
A_B_002 of 002_time1.txt
A_B_001 of 001_time2.txt
Scenarios-
a)If file with 001 of 002_time1 or 002 of 002_time1 is missing in the folder,script should... (6 Replies)
Discussion started by: aneeta13
6 Replies
nl(1) General Commands Manual nl(1)
Name
nl - line numbering filter
Syntax
nl [-h type] [-b type] [-f type] [-v start#] [-i incr] [-p ] [-l num] [-s sep] [-w width] [-n format] [-d delim] file
Description
The command reads lines from the named file or from the standard input, if no file is named, and reproduces the lines on the standard out-
put. Lines are numbered on the left in accordance with the command options in effect.
The command views the text it reads in terms of logical pages. Line numbering is reset at the start of each logical page. A logical page
consists of a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently avail-
able for header, body, and footer. For example, you can elect not to number header and footer lines while numbering blank lines in the
body.
The start of logical page sections is signaled by input lines containing nothing but the following delimiter characters:
Line contents Start of
::: header
:: body
: footer
Unless otherwise specified, assumes that the text it is reading is in the body of a single logical page.
Options
Command options may appear in any order and may be intermingled with an optional file name. Only one file may be named.
-b type Specifies which logical page body lines are to be numbered. The following are recognized types and their meaning: a,
number all lines; t, number lines with printable text only; n, no line numbering; pstring, number only lines that con-
tain the regular expression specified in string.
The default type for logical page body is t (text lines numbered).
-h type Same as -b type except for header. Default type for logical page header is n (no lines numbered).
-f type Same as -b type except for footer. Default for logical page footer is n (no lines numbered).
-p Do not restart numbering at logical page delimiters.
-v start# The initial value used to number logical page lines. Default is 1.
-i incr The increment value used to number logical page lines. Default is 1.
-s sep The character used in separating the line number and the corresponding text line. Default sep is a tab.
-w width The number of characters used for the line number. Default width is 6.
-n format The line numbering format. Recognized values are the following: ln, left justified, leading zeroes suppressed; rn,
right justified, leading zeroes suppressed; rz, right justified, leading zeroes kept. Default format is rn (right jus-
tified).
-l num The number of blank lines to be considered as one. For example, -l2 results in only the second adjacent blank being
numbered (if the appropriate -ha, -ba, or -fa option is set). Default is 1.
-d xx The delimiter characters specifying the start of a logical page section may be changed from the default characters (:)
to two user-specified characters. If only one character is entered, the second character remains the default character
(:). No space should appear between the -d and the delimiter characters. To enter a backslash, you must type two
backslashes (//).
Examples
nl -v10 -i10 -d!+ file1
This command numbers file1 starting at line number 10 with an increment of ten. The logical page delimiters are !+.
See Also
pr(1)
nl(1)