Sponsored Content
Full Discussion: Another script question.
Top Forums UNIX for Dummies Questions & Answers Another script question. Post 453 by Astudent on Monday 4th of December 2000 08:02:37 PM
Old 12-04-2000
This is wat I have, I used "elif" before but it worked the same. Ok the first 2 if statements work but the last 2 don't. For example here are the files in your dir:
10 11.txt 12 14.txt

When you run this script: (called script1)

script1 10 - it doesn't prompt for txt extension!

It should now say "Must have txt extension!"

I don't know what I am doing wrong, this seems so simple but I can't hack it!

Please help,

theA
Code:
if [ "$#" -eq 0 ]
then
    echo "Name required!"
    exit 1
fi

if [ "$#" -gt 1 ]
then
    echo "Only one please!!"
    exit 1
fi

if [ ! -e "$1" ]
then
    echo "Database file \"$1\" does not exist!"
    exit 1
fi

if [ "-f" = ".txt$" ]
then
echo "Database files must contain a "txt" extension!"
    exit 1

fi

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 02:59 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

script question

Correct me if i'm wrong, but by adding "#!/bin/ksh" at the start of a script will force it to run in the korn shell no matter which shell you are currently using?? (2 Replies)
Discussion started by: shad0w75
2 Replies

2. Shell Programming and Scripting

script question

I'm using solaris and i have an old script that an ex employee wrote but i can't seem to get it working. well is just one part of the script if ($?MC_PROD_DIR == 0) setenv MC_PROD_DIR $HOME/PRODUCTION source $MC_PROD_DIR/scripts/localenv ** i understand what this part of the script is... (1 Reply)
Discussion started by: fusionjd
1 Replies

3. UNIX for Dummies Questions & Answers

Script question

Can anyone help with these scripts? Im new to this and struggling. Thank you for your help. Pre-requisites Create a file with x amount of lines in it, the content of your choice. (Have already done this) Script 1 Write a script that takes two arguments. The first being a line of text,... (3 Replies)
Discussion started by: beginner1
3 Replies

4. Shell Programming and Scripting

script question

Anyone know why this won't work? #!/usr/bin/ksh for db in `cat /etc/oratab|egrep ':N|:Y' | grep -v \* | cut -f1 -d":"` do echo "************************" echo "database is $db" echo "************************" done I am getting an error on the line... (7 Replies)
Discussion started by: ace2000
7 Replies

5. Shell Programming and Scripting

Script Question

Here is my problem. I have a txt file with a list of user names in both upper case and lower case. I need to remove the names from the passwd file. I want to be able to run a script that looks at my txt list and then removes those names from the passwd file. It would be nice if it backed up the... (3 Replies)
Discussion started by: wgartin
3 Replies

6. Shell Programming and Scripting

Script question

I am trying to write a script to check the STIG our unix boxes. I want to put in checks to determine if certain files or directories are there. For example: If /opt/SUNWexplo exists echo "Sun Explorer exists" else echo "Sun Explorer is not installed" I am sure I could write... (2 Replies)
Discussion started by: rkruck
2 Replies

7. UNIX for Dummies Questions & Answers

Script Question

I have a script that will calculate some information about the current directory that I run the script in. How can I have it where it gets an argument from the user(such as a directory) and the script calculate the information for the given directory? Any help is greatly appreciated. (8 Replies)
Discussion started by: tr32
8 Replies

8. Shell Programming and Scripting

script question

How can I include a counter in this if statement so only sends out 5 notifications. # the if statement will check for the lines status, if status is down sends email if then LIST="user@email.com" mail -s "rje_lines_down" $LIST < ${tmpfile} #sends an email to list fi thanks... (2 Replies)
Discussion started by: d4n3lu
2 Replies

9. Shell Programming and Scripting

Script question

I know some tricks like this : echo " E"; sleep 0.1; clear; echo " Er"; sleep 0.1; clear; echo " Err"; sleep 0.1; clear; echo " Erro"; sleep 0.1; clear; echo " Error ";... (2 Replies)
Discussion started by: hakermania
2 Replies

10. Programming

C first Script Question

Gents for 2013 I have embarked on learning C and just wrote my first script and need some help. In the learning process, I am trying to understand where I went wrong with my script. The flow of the script is as such: Enter a number --> check if it is a number --> if it is not a number,print what... (4 Replies)
Discussion started by: metallica1973
4 Replies
dos2unix(1)						      General Commands Manual						       dos2unix(1)

NAME
dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)
All times are GMT -4. The time now is 10:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy