Forum Webscript.Ru
Общие => Веб Сервера => Тема начата: Tweak от 22 Февраля 2004, 18:25:30
-
Всем привет!
Есть такой скрипт #!/bin/sh
tar zcf /dir/file_name.tar.gz /dir_with_data/ &
echo "Content-type: text/html";
echo
echo ok
смысл его в том, что он берёт файлы из директории dir_with_data и сжимает их в архив. Но если в этой папке dir_with_data есть еще подкаталоги, он берёт и их.
Вопрос: как сделать, чтобы он не видел подкаталоги, а брал только файлы, лежащие непосредственно в этом каталоге.
Большое спасибо!
-
man tar
-
а можно полный код, как это должно выглядеть, а то я новичок в UNIX
-
:)
TAR(1) FreeBSD General Commands Manual TAR(1)
NAME
tar -- tape archiver; manipulate "tar" archive files
SYNOPSIS
tar [[-]bundled-options Args] [gnu-style-flags]
[filenames | -C directory-name] ...
DESCRIPTION
Tar is short for ``tape archiver\'\', so named for historical reasons; the
tar program creates, adds files to, or extracts files from an archive
file in tar format, called a tarfile. A tarfile is often a magnetic
tape, but can be a floppy diskette or any regular disk file.
The first argument word of the tar command line is usually a command word
of bundled function and modifier letters, optionally preceded by a dash;
it must contain exactly one function letter from the set A, c, d, r, t,
u, x, for append, create, difference, replace, table of contents, update,
and extract (further described below). The command word can also contain
other function modifiers described below, some of which will take argu-
ments from the command line in the order they are specified in the com-
mand word (review the EXAMPLES section). Functions and function modi-
fiers can also be specified with the GNU argument convention (preceded by
two dashes, one function or modifier per word. Command-line arguments
that specify files to add to, extract from, or list from an archive may
be given as shell pattern matching strings.
FUNCTIONS
Exactly one of the following functions must be specified.
-A
--catenate
--concatenate Append the contents of named file, which must itself be a
tar archive, to the end of the archive (erasing the old
end-of-archive block). This has the effect of adding the
files contained in the named file to the first archive,
rather than adding the second archive as an element of the
first. Note: This option requires a rewritable tarfile,
and therefore does not work on quarter-inch cartridge
tapes.
-c
--create Create a new archive (or truncates an old one) and writes
the named files to it.
-d
--diff
--compare Find differences between files in the archive and corre-
sponding files in the file system.
--delete Delete named files from the archive. (Does not work on
quarter-inch tapes).
-r
--append Append files to the end of an archive. (Does not work on
quarter-inch tapes).
-t
--list List the contents of an archive; if filename arguments are
given, only those files are listed, otherwise the entire
table of contents is listed.
-u
--update Append the named files if the on-disk version has a modi-
fication date more recent than their copy in the archive
(if any). Does not work on quarter-inch tapes.
-x
--extract
--get Extract files from an archive. The owner, modification
time, and file permissions are restored, if possible. If
no file arguments are given, extract all the files in the
archive. If a filename argument matches the name of a
directory on the tape, that directory and its contents are
extracted (as well as all directories under that direc-
tory). If the archive contains multiple entries corre-
sponding to the same file (see the --append command
above), the last one extracted will overwrite all earlier
versions.
OPTIONS
The other options to tar may be combined arbitrarily; single-letter
options may be bundled in with the command word. Verbose options which
take arguments will be followed by the argument; single-letter options
will consume successive command line arguments (see the EXAMPLES below).
--help Prints a message listing and briefly describing
all the command options to tar.
--atime-preserve Restore the access times on files which are writ-
ten to tape (note that this will change the
inode-change time!).
-b
--block-size number Sets the block size for reading or writing to
number * 512-byte blocks.
-B
--read-full-blocks Re-assemble short reads into full blocks (for
reading 4.2BSD pipes).
-C directory
--directory directory Change to directory before processing the remain-
....
-
Спасибо, но я имел ввиду пример скрипта, как он должен выглядеть.