Create Year directory, date subdirectory and archive the file
Hi,
After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are
1) Check if the file exists in the current directory.
2) Check if the destination directory exists.
3) If the destination directory exists, then create a Year sub directory under it. If the Year sub directory already exists, then skip to the next step.
4) If the Year sub directory exists, then check if the Date sub directory exists. If it exists, move the file else create the sub directory and move it.
I did work on the script and it is erroring out. I was wondering if this is the right way to do it or is there is a better way to do it.
Hi,
I have written one script to calculate total space of all file in one directory, ignoring subdirectory, it works fine.
Now, I've been trying to calculate all files which includes files in any subdirectories.
I use recursive function to do this, but it can work only if there is only one... (4 Replies)
I am adding some individual files to a tar archive and would like them to be added to the archive without any directory hierarchy, even though the files themselves exist in levels of hierarchy. Unfortunately, tar seems to always preserve the directory hierarchy when it adds the files.
Here is... (2 Replies)
hi all,
here is the description to my problem.
input parameters: $date1 & $date2
based on the range i need to select the archived files from the archived directory and moved them in to working directory.
can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Hi ,
I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level ..
#!/bin/ksh
FNAME='.pdf'
S_PATH=/abc/def/xyz
find $S_PATH -exec ls -lad... (4 Replies)
Suppose i have a word "mail".
I have to search this word in all files inside a directory and it's sub-directories.
It will also search in all hidden directory and sub-directories.
If it finds this word in any file it will list that file.
How can i do this with perl/ruby/awk/sed/bash or... (9 Replies)
Hi Everyone!
Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file.
Any ideas?
Thank you! (1 Reply)
Hi All,
My directory structure is like
Directory1
SubDirectory1
SubDirectory2
SubDirectory3
I have main directories and subdirectories underneath. I want to write a shell script where I will be passing file name as a parameter, Now I want to find all the files in Directory1... (19 Replies)
Hi all,
i have a folder, with tons of files containing as following,
on /my/folder/jobs/
some_name_2016-01-17-22-38-58_some name_0_0.zip.done
some_name_2016-01-17-22-40-30_some name_0_0.zip.done
some_name_2016-01-17-22-48-50_some name_0_0.zip.done
and these can be lots of similar files,... (6 Replies)
Hi there,
Here is what I currently have and trying to come up with a logic to automatically append logs to a respective year file. The log files might get generated everyday or any other day, irrespective of which I want to copy all of the logs for that year into one file /tmp/<year>.log and then... (4 Replies)
Discussion started by: mbak
4 Replies
LEARN ABOUT ULTRIX
ar
ar(1) General Commands Manual ar(1)Name
ar - archive and library maintainer
Syntax
ar option [ posname ] archive file ...
Description
The archiver ar maintains groups of files as a single archive file. This utility is generally used to create and update library files that
the link editor uses; however, you can use the archiver for other similar purposes. This version uses a portable ASCII-format archive that
you can use on various machines that run UNIX. If you have an archive that uses an older format, see
Options
This section describes the options and suboptions that you can use with the ar utility. Suboptions must be specified with options. Fol-
lowing is a list and description of the options:
d Deletes the specified files from the archive file.
r Replaces the specified files in the archive file. If you use the suboption u with r, the archiver only replaces those files that
have last-modified dates later than the archive files. If you use a positioning character (from the set abi) you must specify the
posname argument to tell the archiver to put the new files after (a) or before (b or i). Otherwise, the archiver puts new files at
the end of the archive.
q Appends the specified files to the end of the archive file. The archiver does not accept suboption positioning characters with the
q option. It also does not check whether the files you want to add already exist in the archive. Use the q option only to avoid
quadratic behavior when you create a large archive piece by piece.
t Prints a table of contents for the files in the archive file. If you do not specify any filenames, the archiver builds a table of
contents for all files. If you specify filenames, the archiver builds a table of contents only for those files.
p Prints the specified files from the archive.
m Moves the specified files to the end of the archive. If you specify a positioning character, you must also specify the posname (as
in option r) to tell the archiver where to move the files.
x Extracts the specified files from the archive. If you do not specify any filenames, the archiver extracts all files. When it
extracts files, the archiver does not change any file. Normally, the last-modified date for each extracted file shows the date when
someone extracted it; however, when you use o, the archiver resets the last-modified date to the date recorded in the archive.
s Makes a symbol definition (symdef file) as the first file of an archive. This file contains a hash table of ranlib structures and a
corresponding string table. The symdef file's name is based on the byte ordering of the hash table and the byte ordering of the
file's target machine. Files must be consistent in their target byte ordering before the archiver can create a symdef file. If you
change the archive contents, the symdef file becomes obsolete because the archive file's name changes. If you specify s, the
archiver creates the symdef file as its last action before finishing execution. You must specify at least one other archive option
(m, p, q, r, or t) when you use the s option. For UMIPS-V, archives include member objects based on the definition of a common
object only. For UMIPS-BSD, they define the common object, but do not include the object.
v Gives a file-by-file description as the archiver makes a new archive file from an old archive and its constituent files. When you
use this option with t, the archiver lists all information about the files in the archive. When you use this option with p, the
archiver precedes each file with a name.
c Suppresses the normal message that the archiver prints when it creates the specified archive file. Normally, the archiver creates
the specified archiver file when it needs to.
l Places temporary files in the local directory. If the l option is not used then the value of the environment symbol, TMPDIR, is
used as the directory for temporary files. If TMPDIR is not defined or if the directory it references is not writable then /tmp is
used.
The suboptions do these things:
a Specifies that the file goes after the existing file (posname). Use this suboption with the m or r options.
b Specifies that the file goes before the existing file (posname). Use this suboption with the m or r options.
i Specifies that the file goes before the existing file (posname). Use this suboption with the m or r options.
o Forces a newly created file to have the last-modified date that it had before it was extracted from the archive. Use this suboption
with the x option.
u Prevents the archiver from replacing an existing file unless the replacement is newer than the existing file. This option uses the
UNIX system last modified date for this comparison. Use this suboption with the r option.
Restrictions
If you specify the same file twice in an argument list, it can appear twice in the archive file.
The o option does not change the last-modified date of a file unless you own the extracted file or you are the superuser.
This command truncates filenames to 15 characters.
Files
/tmp/v* temporaries
See Alsolorder(1), ld(1), odump(1), ranlib(1), ranhash(3x), ar(5), arcv(8)
RISC ar(1)