Hi,
bash tells you "command not found" because you typed [-f ... without spaces,
anyway the option "-f" check a single file so even if you write the if statement the right way, the code you posted won't work.
Anyway if you want to delete files you can try this:
if you want to send the directory as a parameter of the script, you can try what follow
./script_to_delete_files.sh <directory>
in your code you'll write:
[[ -z "$1" ]] && echo "you must enter a dir" && exit 0
[[ ! -d "$1" ]] && echo "Directory $1 doesn't exist" && exit 0
for FILES in $(cat <filestodelete>); do
rm /path_before_your_directory/$1/$FILES
done
Hope it helps
Bye
Last edited by Yogesh Sawant; 04-13-2009 at 07:32 AM..
Reason: added code tags
Hi All,
I have a report which I am running from unix shell script using CONCSUB utility.
Just for testing I put the order number in shell script as ord_low and ord_high.
But Actually what is going to happen is that the order numbers will be in a file say a.txt
and this CONCSUB should... (0 Replies)
hi
How can one change an environment varaible inside a shell script
say my bash shell has a env variable export FOO="Day"
no i want to write a script inside which the FOO variable is modified to say
export FOO=NIGHT
after this script finishes te bash shell should show me NIGHT when i... (1 Reply)
Hello,
I have several files in a specific directory.
A specific string in one file can occur in another files.
If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string.
Example.
file1
ShortName "Blue... (2 Replies)
Hi all,
I need a script to delete a large set of files from a directory under / based on an input file and want to redirect errors into separate file.
I have already prepared a list of files in the input file.
Kndly help me.
Thanks,
Prash (36 Replies)
Hi,
I am looking for a shell script which serves the below purpose.
Please find below the algorithm for the same and any help on this would be highly appreciated.
1)set of strings need to be replaced among set of files(directory may contain different types of files)
2)It should search for... (10 Replies)
he following are the files available in my directory
RSK_123_20141113_031500.txt
RSK_123_20141113_081500.txt
RSK_126_20141113_041500.txt
RSK_126_20141113_081800.txt
RSK_128_20141113_091600.txt
Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Hi
My directory structure is as below.
dir1, dir2, dir3
I have the list of files to be deleted in the below path as below.
/staging/retain_for_2years/Cleanup/log $ ls -lrt
total 0
drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2
drwxr-xr-x 2 root ... (2 Replies)
Hi.
My example:
I have a filesystem /log. Everyday, log files are copied to /log. I'd like to set owner and permission for files and directories in /log like that
chown -R log_adm /log/*
chmod -R 544 /log/*It's OK, but just at that time. When a new log file or new directory is created in /log,... (8 Replies)
Discussion started by: bobochacha29
8 Replies
LEARN ABOUT OSF1
script
script(1) General Commands Manual script(1)NAME
script - Makes a transcript of terminal session
SYNOPSIS
script [-a] [file]
The script command makes a transcript of everything printed on your terminal.
OPTIONS
Appends the transcript to file rather than writing it to file.
OPERANDS
The name of an output file that will contain the transcript of the session. If this parameter is omitted, the file typescript is written.
DESCRIPTION
The transcript is written to file, or appended to file if the -a option is given. If no file name is given, the transcript is saved in the
file typescript.
The script ends when the forked shell exits.
This program is useful when you are using a CRT and want a hard-copy record of the dialog (for example, a technical writer might create an
example of a working session this way).
If you specify the -a option and the file does not exist, it is created.
If you do not specify the -a option and the file exists, it is replaced.
RESTRICTIONS
The script command requires a streams based terminal. In single user mode, streams may not be enabled. Under these circumstances, script
will exit with no action. If you are the superuser and need to run this command in single user mode, use the following special instruc-
tions.
Enabling Streams
If it is necessary to enable a streams environment in the single user mode, enter the command /sbin/init.d/streams. This command is avail-
able to the superuser only.
SEE ALSO
Commands: autopush(8), cat(1), echo(1), strsetup(8), tee(1)
System Administration
script(1)