Sponsored Content
Top Forums Shell Programming and Scripting Add column that shows how old a file is Post 302372727 by cdunavent on Wednesday 18th of November 2009 03:10:07 PM
Old 11-18-2009
The syntax:

Code:
$ cat test
#!/bin/ksh
for FILENAME in /home/voicem/ivr/arivra
do
let AGE=(`date %s`-`date -r $FILENAME %s`)/86400
done


Results of running script:

$ ./test
./test: syntax error at line 4: `(' unexpected

Last edited by cdunavent; 11-18-2009 at 04:26 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add a particular column alone in a file

Hi I have file which contains 5 coulmns i need to add the fifth column value and put it in the desired location in the same column. Here is the sample file.. ashop0004 SQL- 06/14/2009 06/14/2009 00:04:28 SUM ashop0004 SQL- 06/14/2009 06/14/2009 00:00:37 ... (22 Replies)
Discussion started by: cutechaps
22 Replies

2. Shell Programming and Scripting

Need to add letters to a column and add in a new column subtracting from another column

So I have this input 1 10327 rs112750067 T C . PASS DP=65;AF=0.208;CB=BC,NCBI 1 10469 rs117577454 C G . PASS DP=2055;AF=0.020;CB=UM,BC,NCBI 1 10492 rs55998931 C T . PASS DP=231;AF=0.167;CB=BC,NCBI 1 10583 rs58108140 G A ... (3 Replies)
Discussion started by: kellywilliams
3 Replies

3. Shell Programming and Scripting

Add column to a file

Hola, How can I add a column to a existing file?? PS: The column which should be added need to be the first column and it will be a parameter from the script. Example: 1 name1 2 name2 3 name3 4 name3 Need to add parameter $file as a first column. $file is a file name with time... (6 Replies)
Discussion started by: Olivia
6 Replies

4. Shell Programming and Scripting

How to add a column from other file?

Dear all, Lets say, I've a file a.txt containing two columns, like a1 b1 .. .. .. .. and another file b.txt containg two columns, like a1 c1 .. .. .. .. I need to put c1 column from b.txt file to the a.txt file. So, the output should be a1 b1 c1 .. .. .. .. ... (4 Replies)
Discussion started by: mkg
4 Replies

5. Shell Programming and Scripting

How to add day of week at the end of each line that shows the date?

I have a file that looks like: file1: www_blank_com 20121008153552 www_blank_com 20121008162542 www_blank_com 20121009040540 www_blank_com 20121009041542 www_blank_com 20121010113548 www_blank_com 20121011113551 www_blank_com 20121012113542 I want the new file to show the day of... (3 Replies)
Discussion started by: castrojc
3 Replies

6. Shell Programming and Scripting

Help with add existing file name as new data column in new output file

Input File 1 cat S1.txt MI0043 2731 miR-1 Input File 2 cat S4.txt MI006 310 CiR-1 MI057 10 CiR-24 MI750 5 CiR-24 Desired Output File 1 cat S1.txt.out MI0043 2731 miR-1 S1.txt Desired Output File 2 cat S4.txt.out MI006 310 CiR-1 S4.txt (3 Replies)
Discussion started by: perl_beginner
3 Replies

7. Shell Programming and Scripting

Add a new column to file

I have file like this b,c 10,20 30,40 50,60 Now I want to add a new column a with fixed values for all the rows a,b,c 60,10,20 60,30,40 60,50,60 Please let me know how can we do this in unix. (4 Replies)
Discussion started by: weknowd
4 Replies

8. UNIX for Dummies Questions & Answers

Add a column to a file

Hi, I have this data file that contains: 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H 9 I I want the results to be: 1 A A 2 B A 3 C A 4 D A 5 E A 6 F A 7 G A 8 H A (8 Replies)
Discussion started by: bobo
8 Replies

9. Shell Programming and Scripting

Add new column in the file

Hi Team I have file as below empno,ename,sal 123,smith,1000 124,adams,2000 Required output: Using AWK empno,ename,sal,deptno 123,smith,1000 124,adams,2000 Thanks, Murali (5 Replies)
Discussion started by: bmk
5 Replies

10. UNIX for Beginners Questions & Answers

Add new column from another file

Hi, I have 2 files. file1 contains by lines: hash:salt:id file2 contains by lines: username:hash:salt I would like to add a new coloumn (id) form file1 to file2. The new file should contains: username:hash:salt:id Note: file1 contains less rows than file2. I tried paste -d':' file1... (12 Replies)
Discussion started by: freeroute
12 Replies
MANILIST(1)						      General Commands Manual						       MANILIST(1)

NAME
manilist - report status of files in a source directory SYNOPSIS
manilist [ -abcdhnptV ] [ -i extension ] [ -f manifest ] [ -p format ] [ -s string ] [ -w which ] [ -x extension ] [ -C separator ] [ -I included ] [ -L colsize ] [ -X excluded ] [ files or directories ] DESCRIPTION
Manilist scans a source directory and produces a report on the status of each file: whether it is up-to-date or not with respect to patch- level.h , if it is missing from MANIFEST.new, and some other useful information which may be dynamically configured. It can be use to main- tain a MANIFEST.new file, produce a detailed listing and status of a group of directories, etc... The rich set of options concur to make manilist a perfect low-level tool. Under its simplest invocation form at the top level directory of a package, with no arguments, manilist will scan the MANIFEST.new and pro- duce a report on the status of each file listed there. Each line starts with a single character flag which indicates the state of the file, followed by the name of the file. What happens in fact is more complex than that. Manilist scans the MANIFEST.new file and then loops over all the files listed there. Inter- nally, manilist maintains an inclusion and an exclusion list, both specifying extensions for files. For instance, the inclusion list could be ('.c', '.h') and the exclusion ('.o', ',v') so that C sources are included and object or RCS files excluded. By default, all files but those excluded are used. Some other selections may be applied at this stage, as will be explained later on. For those files which pass this selection process, a report is issued according to a report format, which by default is "A:%c %n". The letter A (or anything before the initial ':' character is the file selection specification we've been talking about. The remaining is the formatting, a string which is printed as-is, modulo some escape sequences. It so happens that %c is the character flag and %n is the name of the current file. Generally speaking, manilist should be regarded as a tool which emits configurable reports on a set of files, selectively picking them among a list or by directly scanning the directories to see what's out there... By specifying a set of directories or files as arguments on the command line, you restrict the scanning area, limiting to reports concern- ing those files or directories. If you do not specify any, manilist restricts its report to the current directory and its subdirectories, unless the -t option is given. OPTIONS
Manilist recognizes the following options: -a Make a report for all the files, regardless of what is specified by the included and excluded suffix lists. -b Assume current directory is the base (root) of the package tree. When this option is not specified, manilist will look for a .package file to indicate the root directory of the package (also called the top) and complain if it does not find it. -c Check files against those listed in MANIFEST.new (or whatever file specified via the -f option) and report discrepancies via the %c macro. -d Dump included and excluded suffix lists on stderr, extensions being space separated. A good way to know the default lists is to run: manilist -f /dev/null -bd. -f manifest Specify an alternate manifest file, the default being to use MANIFEST.new. -h Print the usage help message and exit. -i extensions Add new extensions to the included suffix list. The extensions argument must list the suffixes separated by spaces, as in -i '.ph .pl' to add both .ph and .pl to the existing suffixes. Note that the argument needs to be quoted to protect spaces against shell interpretation. -n Do not use any manifest file. Rather scan the directories and act as with all the files there were already listed in a mani- fest. -p format Set the new printing format, which has the form selection:string, with selection being a list of single letters specifying which files from the manifest are to be used for reports, and string being a message to print as report, with some macro substitutions. It is also possible to have column formatting by specifying a '|' inside the string to delimit the different columns you wish to see. See also -C and -L for more formatting parameters. -s string Specify the string part of the printing format (see -p for a general description of the format). Available macros are listed further down the manual page. -t Start from the top directory (the root directory of the distribution) regardless of the current directory. There must be a .package file to indicate what the top directory is. -w selection Specifiy the selection part of the printing format. Available selections will be discussed later. -x extensions Add new extensions to the excluded suffix list. The extensions argument must list the suffixes separated by spaces, as in -x '.s .p' to add both .s and .p to the existing list. Note that the argument needs to be quoted to protect spaces against shell interpretation. -C separator Give the column separator, which is to be used in place of the '|' character in the report format string. By default, it is a single space. -I included Specify a new list of suffixes to be included in the reports. This overrides the original default list (whereas -i is used to add suffixes to the list). Suffixes must be space separated. -L colsize When using column formatting (the '|' character being used to denote columns), this option may be used to specify the maxi- mum column width, separating each width by a single ','. Leaving a width unspecified does not impose any limit on its width. For instance, if the format string is %n|%d|%t, one could limit the middle column (descriptions from MANIFEST.new) to 40 characters and the name column (first one) to 15 characters, leaving the last one with no imposed limits, by using -L 15,40,. -V Print version number and exit. -X excluded Specify a new list of suffixes to be excluded in the reports. This overrides the original default list (whereas -x is used to add suffixes to the list). Suffixes must be space separated. USING FORMATS
The flexibility of manilist is brought by its use of a dynamic formatting string for providing its reports. It is possible to specify a format via the -p option or just parts of it: the text string via -s and the file selection with -w. File Selection The leading part of the formatting string tells manilist which files you wish to see in the final report. Available selectors are: A All the files but the excluded ones (i.e. those files whose suffix is listed in the exclusion list). This is the default action. a All the files included and/or excluded (shortcut for ix). Note that files which are neither included nor excluded will not appear in the report. d Report only for directories. f Report only for files. i Only included files are listed. m Only those files or directories found in the manifest are listed. n Only those files or directories not found in the manifest are listed. x Only excluded files are listed. When you specify more than one letter, the resulting report depends on the nature of the selection. For d, f, m and n, a logical union is performed. This means specifying fd or mn is the same as not specifying anything, but it's less efficient since manilist is forced to per- form the checks it would otherwise bypass. The i and x selectors are special: by default, all the files not excluded are reported. Speci- fying x also asks for excluded files. Specifying i restricts the report to the included files. Using both at the same time (ix) will force a report for files which are included or excluded. Macro Substitution The string part of the report format can make use of the following macros: %c A character coding the status of the file. %d Description from the manifest file, if any. %n Name of the file (its path from the top directory). %s Size of the file, in bytes. %t Time stamp of the last modification. File Status The %c macro, giving a single character coding the file status, can expand into one of the following. . The file is up to date (not newer than patchlevel.h). - The file is present in the manifest but is missing. > The file has been modified since last patch (newer than patchlevel.h). + The file exists but is not listed in the manifest. o The file exists but is not listed in the manifest and is older than patchlevel.h x The file is listed in the manifest and exists, but has been excluded. Naturally, this will appear in the report only if the x selector is given in the report format. ? The file is listed in the manifest, does not exist, and was excluded. EXAMPLES
The command manilist -ct -p 'ni:%n' will list all the source files from your distribution which are not listed in your MANIFEST.new file. Note that this includes only "source" files, that is to say files whose extension is listed in the inclusion list. If you do not wish this restriction, replace the formatting string with n:%n (only the excluded files will not appear). To build an initial MANIFEST file, use: manilist -n -p 'Af:%n' > MANIFEST from the top directory. You will eventually want to fill in descriptions for each file listed in the manifest. FILES
MANIFEST.new Default manifest file, listing files and giving a small description for each of them. AUTHOR
Raphael Manfredi <ram@hptnos02.grenoble.hp.com> SEE ALSO
manifake(1), makedist(1), pat(1). ram MANILIST(1)
All times are GMT -4. The time now is 12:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy