Sponsored Content
Top Forums Shell Programming and Scripting want to concatenate multiple files based on the rest of ls -lrt Post 302450150 by mail2sant on Wednesday 1st of September 2010 08:51:49 PM
Old 09-01-2010
Code:
#!/bin/sh


ls -ltr /home/data/log/  | `awk -vd=`date +"%b"` ' $6==d { system("cat " $NF " >> /home/data/singlefile" ) }'`





=============

getting the below error


Code:
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:          GNU long options:
        -f progfile             --file=progfile
        -F fs                   --field-separator=fs
        -v var=val              --assign=var=val
        -m[fr] val
        -W compat               --compat
        -W copyleft             --copyleft
        -W copyright            --copyright
        -W dump-variables[=file]        --dump-variables[=file]
        -W exec=file            --exec=file
        -W gen-po               --gen-po
        -W help                 --help
        -W lint[=fatal]         --lint[=fatal]
        -W lint-old             --lint-old
        -W non-decimal-data     --non-decimal-data
        -W profile[=file]       --profile[=file]
        -W posix                --posix
        -W re-interval          --re-interval
        -W source=program-text  --source=program-text
        -W traditional          --traditional
        -W usage                --usage
        -W version              --version

To report bugs, see node `Bugs' in `gawk.info', which is
section `Reporting Problems and Bugs' in the printed version.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
        gawk '{ sum += $1 }; END { print sum }' file
        gawk -F: '{ print $1 }' /etc/passwd
mt.sh: line 5:  $6==d { system("cat " $NF " >> /home/data/singlefile" ) }: No such file or directory

Sep

Moderator's Comments:
Mod Comment At over 80 posts, you should know how to use code tags

Last edited by pludi; 09-02-2010 at 02:01 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find multiple patterns on multiple lines and concatenate output

I'm trying to parse COBOL code to combine variables into one string. I have two variable names that get literals moved into them and I'd like to use sed, awk, or similar to find these lines and combine the variables into the final component. These variable names are always VAR1 and VAR2. For... (8 Replies)
Discussion started by: wilg0005
8 Replies

2. Shell Programming and Scripting

Concatenate multiple lines based.

Hello, I have been searching the forum for concatenation based on condition. I have been close enough but not got th exact one. infile: -----DB_Name ABC (X, Y,Z). DB_Name DEF (T). DB_Name GHI (U ,V,W). Desired Output file should be: ---------------------------DB_Name ABC... (8 Replies)
Discussion started by: indrajit_u
8 Replies

3. Shell Programming and Scripting

Concatenate columns from multiple files

Hi all, I want the 2nd column of every file in the directory in a single file with the file name as column header. $cat file1.txt a b c d e f $cat file2.txt f g h g h j $cat file3.txt a b d f g h (2 Replies)
Discussion started by: newbie83
2 Replies

4. UNIX for Dummies Questions & Answers

What does total no. of files in ls -lrt o/p means?

when we fire ls -lrt command we see o/p as total 16 drwx------ 9 root root 8192 May 8 2002 lost+found drwxr-xr-x 2 root root 512 Jun 14 2002 TT_DB drwxrwxr-x 2 root root 512 Jul 31 2002 mail here total no. of files is always greater than... (4 Replies)
Discussion started by: Jcpratap
4 Replies

5. Shell Programming and Scripting

Divide an EBCDIC files into multiple files based on value at 45-46 bytes

Hi All, I do have an EBCDIC file sent from the z/os , this file has records with different record types in it, the type of record is identified by bytes 45-46 like value 12 has employee record value 14 has salaray record and etc.... we do now want to split the big ebcdic file into multiple... (3 Replies)
Discussion started by: okkadu
3 Replies

6. Shell Programming and Scripting

How to concatenate the files based upon the file name?

Hi Experts, I am trying to merge multiple files into one file based upon the file name. Testreport_Server1.txt ============ MonitoringReport_Server1.txt============ CentralReport_Server1 Here two files containing server1 should be merged into one file? How can i do... (16 Replies)
Discussion started by: sharsour
16 Replies

7. Shell Programming and Scripting

Concatenate select lines from multiple files

I have about 6000 files of the following format (three simplified examples shown; actual files have variable numbers of columns, but the same number of lines). I would like to concatenate the ID (*Loc*) and data lines, but not the others, as shown below. The result would be one large file (or... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

8. Shell Programming and Scripting

Merge two input files and concatenate the rest

Hi Guys, I need a help to creating a bash script to merging two files that containing not in order pattern into single file also within that single file I need to concatenate and manipulate the string from two files. Appreciate for any kind help given. Thanks. Here are the input files:... (3 Replies)
Discussion started by: jabriel
3 Replies

9. Shell Programming and Scripting

Concatenate files based on names

Dear all, I have a list of files and I woulk like to concatenate some of them based on their name. Basically my files are names like that: file1_abcd_other_useless_letters_1_C1.txt file1_abcd_other_useless_letters_1_C2.txt file1_xywz_other_useless_letters_1_C1.txt... (4 Replies)
Discussion started by: giuliangiuseppe
4 Replies

10. UNIX for Beginners Questions & Answers

Concatenate column values when header is Matching from multiple files

there can be n number of columns but the number of columns and header name will remain same in all 3 files. Files are tab Delimited. a.txt Name 9/1 9/2 X 1 7 y 2 8 z 3 9 a 4 10 b 5 11 c 6 12 b.xt Name 9/1 9/2 X 13 19 y 14 20 z 15 21 a 16 22 b 17 23 c 18 24 c.txt Name 9/1 9/2... (14 Replies)
Discussion started by: Nina2910
14 Replies
lint(1) 						      General Commands Manual							   lint(1)

Name
       lint - a C program checker

Syntax
       lint [ option ] ... file ...

Description
       The command attempts to detect features of the C program files that are likely to be errors, nonportable, or wasteful.  It also checks type
       usage more strictly than the compilers.	Among the things that are currently detected are unreachable statements, loops not entered at  the
       top,  automatic	variables  declared  and  not  used, and logical expressions whose value is constant.  Moreover, the usage of functions is
       checked to locate functions that return values in some places, but not in others, functions called with varying numbers or types  of  argu-
       ments, and functions whose values are not used or whose values are used but none returned.

       Arguments  whose  names end with are interpreted as C source files.  Arguments whose names end with interpreted as the result of an earlier
       invocation of with either the -c or the -o option used.	The files are analogous to (object) files that are produced by	the  command  when
       given a file as input.  Files with other suffixes are warned about and ignored.

       The command takes all the and (specified by -lx) files and processes them in their command line order.  By default, the command appends the
       standard C library to the end of the list of files.  However, if the -p option is used, the portable C library is appended  instead.   When
       the  -c option is not used, the second pass of checks this list of files for mutual compatibility.  When the -c option is used, the and the
       files are ignored.

Options
       Any number of options may be used, in any order, intermixed with filename arguments.  The following options are used  to  suppress  certain
       kinds of warning:

       -a   Suppress warnings about assignments of long values to variables that are not long.

       -b   Suppress warnings about break statements that cannot be reached.  (Programs produced by or often result in such warnings).

       -h   Do not apply heuristic tests that attempt to intuit bugs, improve style, and reduce waste.

       -u   Suppress warnings about functions and external variables used and not defined, or defined and not used.  (This option is suitable when
	    running on a subset of files of a larger program).

       -v   Suppress complaints about unused arguments in functions.

       -x   Do not report variables referred to by external declarations but never used.

       The following arguments alter the behavior of

       -lx  Include additional library For example, you can include a version of the Math Library by inserting -lm  on	the  command  line.   This
	    argument does not suppress the default use of
	    These  lint  libraries  must  be  in the assumed directory.  This option can be used to reference local libraries and is useful in the
	    development of multi-file projects.

       -n   Do not check compatibility against either the standard or the portable library.

       -p   Attempt to check portability to other dialects (IBM and GCOS) of C.  Along with stricter checking, this option causes all non-external
	    names to be truncated to eight characters and all external names to be truncated to six characters and one case.

       -c   Cause  to  produce	a file for every file on the command line. The files are the product of the command's first pass only, and are not
	    checked for inter-function compatibility.

       -o lib
	    Cause to create a lint library with the name The -c option nullifies any use of the -o option.  The library produced is the input that
	    is	given  to the second pass The -o option simply causes this file to be saved in the named library.  To produce a without extraneous
	    messages, use of the -x option is suggested.  The -v option is useful if the source files for the library are just external interfaces
	    (for  example, the way the file is written).  These option settings are also available through the use of comments which are described
	    later.

       The -D, -U, and -I options of and the -g and -O options of are also recognized as separate arguments.  The -g and -O options  are  ignored,
       but,  by  recognizing  these  options,  the behavior of is closer to that of the command's second pass.	Other options are warned about and
       ignored.  The pre-processor symbol lint is defined to allow certain questionable code to be altered or removed for  Therefore,  the  symbol
       lint should be thought of as a reserved word for all code that is planned to be checked by

       The  command  produces  its first output on a per-source-file basis.  Warnings regarding included files are collected and printed after all
       source files have been processed.  Finally, if the -c option is not used, information gathered  from  all  input  files	is  collected  and
       checked	for  consistency.   At this point, if it is not clear whether a warning stems from a given source file or from one of its included
       files, the source file name is printed followed by a question mark.

       The behavior of the -c and the -o options allows for incremental use of on a set of C source files.  Generally, one invokes once  for  each
       source  file with the -c option.  Each of these invocations produces a file which corresponds to the file, and prints all messages that are
       about just that source file.  After all the source files have been separately run through it is invoked once more (without the -c  option),
       listing	all the files with the needed -lx options.  This prints all the inter-file inconsistencies.  This scheme works well with it allows
       to be used to only the source files that have been modified since the last time the set of source files were checked by

Restrictions
       The system call the function and other functions that do not return a value are not interpreted correctly by the command.

       Certain conventional comments in the C source change the behavior of

       /*NOTREACHED*/	 at appropriate points stops comments about unreachable code.  (This comment is typically placed just after calls to func-
			 tions like

       /*VARARGSn*/	 suppresses the usual checking for variable numbers of arguments in the following function declaration.  The data types of
			 the first n arguments are checked; a missing n is taken to be 0.

       /*ARGSUSED*/	 turns on the -v option for the next function.

       /*LINTLIBRARY*/	 at the beginning of a file shuts off complaints about unused functions and function arguments	in  this  file.   This	is
			 equivalent to using the -v and -x options.

Files
       /usr/lib/cmplrs/cc/lint
			   the directory where the lint libraries specified by the -lx option must exist

       /usr/lib/cmplrs/cc/lint[12]
			   first and second passes

       /usr/lib/cmplrs/cc/lint/llib-lc.ln
			   declarations for C Library functions (binary format; source is in

       /usr/lib/cmplrs/cc/lint/llib-lcV.ln
			   System V declarations for standard functions

       /usr/lib/cmplrs/cc/lint/llib-lcP.ln
			   POSIX declarations for standard functions

       /usr/lib/cmplrs/cc/lint/llib-port.ln
			   declarations for portable functions (binary format; source is in

       /usr/lib/cmplrs/cc/lint/llib-lm.ln
			   declarations for Math Library functions (binary format; source is in

       /usr/tmp/*lint*	   temporaries

See Also
       cc(1), cpp(1), make(1)

								       RISC								   lint(1)
All times are GMT -4. The time now is 02:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy