Sponsored Content
Full Discussion: Another script question.
Top Forums UNIX for Dummies Questions & Answers Another script question. Post 441 by PxT on Monday 4th of December 2000 02:03:51 PM
Old 12-04-2000
Maybe you could do something like this to check for an extension:

Code:
echo $1 | grep ".txt$" 1>/dev/null
status=$?

if [ $status -eq 0 ] 
then
	echo "found .txt extension"
else
	echo "not found"
fi

Not sure if that is what you are asking...?
 

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
SCRIPT(1)							   User Commands							 SCRIPT(1)

NAME
script - make typescript of terminal session SYNOPSIS
script [options] [file] DESCRIPTION
script makes a typescript of everything displayed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves the dialogue in this file. If no filename is given, the dialogue is saved in the file type- script. OPTIONS
-a, --append Append the output to file or to typescript, retaining the prior contents. -c, --command command Run the command rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -e, --return Return the exit code of the child process. Uses the same format as bash termination on signal termination exit code is 128+n. -f, --flush Flush output after each write. This is nice for telecooperation: one person does `mkfifo foo; script -f foo', and another can supervise real-time what is being done using `cat foo'. --force Allow the default output destination, i.e. the typescript file, to be a hard or symbolic link. The command will follow a symbolic link. -q, --quiet Be quiet (do not write start and done messages to standard output). -t[file], --timing[=file] Output timing data to standard error, or to file when given. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. -V, --version Display version information and exit. -h, --help Display help text and exit. NOTES
The script ends when the forked shell exits (a control-D for the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. It is not recommended to run script in non-interactive shells. The inner shell of script is always interactive, and this could lead to unexpected results. If you use script in the shell initialization file, you have to avoid entering an infinite loop. You can use for example the .profile file, which is read by login shells only: if test -t 0 ; then script exit fi You should also avoid use of script in command pipes, as script can read more input than you would expect. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1) HISTORY
The script command appeared in 3.0BSD. BUGS
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. script is primarily designed for interactive terminal sessions. When stdin is not a terminal (for example: echo foo | script), then the session can hang, because the interactive shell within the script session misses EOF and script has no clue when to close the session. See the NOTES section for more information. AVAILABILITY
The script command is part of the util-linux package and is available from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils /util-linux/>. util-linux June 2014 SCRIPT(1)
All times are GMT -4. The time now is 04:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy