Sponsored Content
Top Forums Shell Programming and Scripting Help Needed with File Checker Korn Shell Script Post 303042887 by vgersh99 on Thursday 9th of January 2020 12:12:19 PM
Old 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

Shell script syntax checker

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

Korn Shell Help Needed

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

korn shell script to keep history of same file

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

Help needed in character replacement in Korn Shell

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

Korn Shell script needed

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

Shell syntax checker available, or is a new project needed?

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

Monitor file generation for an hour using Korn shell script

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

Write output to a file using Korn shell script

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

Help needed in Korn Shell 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

Validate file count in korn shell script

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
sh(1)							      General Commands Manual							     sh(1)

NAME
sh - overview of various system shells SYNOPSIS
POSIX Shell option] ... string] [arg ...] option] ... string] [arg ...] Korn Shell option] ... string] [arg ...] option] ... string] [arg ...] C Shell [command_file] [argument_list ...] Key Shell DESCRIPTION
Remarks The POSIX .2 standard requires that, on a POSIX-compliant system, executing the command activates the POSIX shell (located in file on HP-UX systems), and executing the command produces an on-line manual entry that displays the syntax of the POSIX shell command-line. However, the command has historically been associated with the conventional Bourne shell, which could confuse some users. To meet stan- dards requirements and also clarify the relationships of the various shells and where they reside on the system, this entry provides com- mand-line syntax and a brief description of each shell, and lists the names of the manual entries where each shell is described in greater detail. The Bourne shell is removed from the system starting with HP-UX 11i Version 1.5. Please use the POSIX shell as an alternative. Shell Descriptions The HP-UX operating system supports the following shells: POSIX-conforming command programming language and command interpreter residing in file Can execute commands read from a terminal or a file. This shell conforms to current POSIX standards in effect at the time the HP-UX system release was introduced, and is similar to the Korn shell in many respects. Similar in many respects to the Korn shell, the POSIX shell contains a history mechanism, supports job control, and provides various other useful features. Korn-shell command programming language and commands interpreter residing in file Can execute commands read from a terminal or a file. This shell, like the POSIX shell, contains a his- tory mechanism, supports job control, and provides various other useful features. A command language interpreter that incorporates a command history buffer, C-language-like syntax, and job control facilities. Restricted version of the POSIX shell command interpreter. Sets up a login name and execution environment whose capabilities are more controlled (restricted) than normal user shells. restricted version of the Korn-shell command interpreter Sets up a login name and execution environment whose capabilities are more controlled (restricted) than normal user shells. An extension of the standard Korn Shell that uses hierarchical softkey menus and context-sensitive help. +--------------+--------------------+ | To obtain: | Use the command: | +--------------+--------------------+ | POSIX Shell | /usr/bin/sh ... | | Korn Shell | /usr/bin/ksh ... | | C Shell | /usr/bin/csh ... | | Key Shell | /usr/bin/keysh | +--------------+--------------------+ These shells can also be the default invocation, depending on the entry in the file. See also chsh(1). WARNINGS
Many manual entries contain descriptions of shell behavior or describe program or application behavior similar to ``the shell'' with a ref- erence to ``see sh(1)''. SEE ALSO
For more information on the various individual shells, see: keysh(1) Key Shell description. ksh(1) Korn Shell description. sh-posix(1) POSIX Shell description. csh(1) C Shell description. sh(1)
All times are GMT -4. The time now is 08:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy