Sponsored Content
Top Forums Shell Programming and Scripting Reading specific contents from 1 input files and appending it to another input file Post 302227591 by Franklin52 on Thursday 21st of August 2008 02:28:42 PM
Old 08-21-2008
Code:
awk -F",| |\\\." 'NR==FNR{a[$1]=$2;next}
$4 in a{print $0 "," a[$4]}
' file2 file1

Use nawk, gawk or /usr/xpg4/bin/awk on Solaris.

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading specific contents from a file and appending it to another file

Hi, I need to write a shell script (ksh) to read contents starting at a specific location from one file and append the contents at specific location in another file. Please find below the contents of the source file that I need to read the contents from, File 1 -----# more... (5 Replies)
Discussion started by: dnicky
5 Replies

2. Shell Programming and Scripting

awk reading 2 input files but not getting expected value

I'm reading 2 input files but not getting expected value. I should get an alpha value on file_1_data but not getting any. Please help. >cat test6.sh awk ' FILENAME==ARGV { file_1_data=$0; print "----- 1 Line " NR " -----" $1; next } FILENAME==ARGV { file_2_data=$0; print "----- 2... (1 Reply)
Discussion started by: pdtak
1 Replies

3. Shell Programming and Scripting

Reading input files

Okay, so I've looked on here and found some similar things, but not exactly what I am looking for. I am working on creating a script that can back up some files, based on the contents of another file - the configuration file. First file contains the files to back up - we'll call this... (1 Reply)
Discussion started by: pdxwarrior
1 Replies

4. Shell Programming and Scripting

Create Multiple files by reading a input file and changing the contents

Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me . Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer. I want to create a mutiple output files with each file having a... (2 Replies)
Discussion started by: bhargavkr
2 Replies

5. Shell Programming and Scripting

Search & Replace in Multiple Files by reading a input file

Hi, I have a folder which contains multiple config.xml files and one input file, Please see the below format. Config Files format looks like :- Code: <application name="SAMPLE-ARCHIVE"> <NVPairs name="Global Variables"> <NameValuePair> ... (0 Replies)
Discussion started by: haiksuresh
0 Replies

6. Shell Programming and Scripting

Help with reading two input files in awk

Hello, I'm trying to write an awk program that reads two files inputs. example, file 1: 0.00017835 0.000176738 0.00018811 0.000189504 0.000188155 0.000180065 0.000178991 0.000178252 0.000182513 file 2: 1.7871769E-05 1.5139576E-16 1.5140196E-16 1.5139874E-16 1.7827407E-04 ... (5 Replies)
Discussion started by: joseamck
5 Replies

7. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

8. Shell Programming and Scripting

Search & Replace in Multiple Files by reading a input file

I have a environment property file which contains: Input file: value1 = url1 value2 = url2 value3 = url3 and so on. I need to search all *.xml files under directory for value1 and replace it with url1. Same thing I have to do for all values mentioned in input file. I need script in unix bash... (7 Replies)
Discussion started by: Shamkamde
7 Replies

9. UNIX for Advanced & Expert Users

Appending a files contents to the end of a specific file name in several directories

Here is my dir structure: /tmp/dave/myappend.txt /tmp/dave/dir1/test.txt /tmp/dave/dir2/test.txt /tmp/dave/dir3/test.txt /tmp/dave/dir4/test.txt I want to append the contents of myappend.txt to the end of each file with the name "test.txt" in all dirs in /tmp/dave/ I have tried this:... (2 Replies)
Discussion started by: bigd213
2 Replies

10. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies
ARCHIVE(8)						      System Manager's Manual							ARCHIVE(8)

NAME
archive - Usenet article archiver SYNOPSIS
archive [ -a archive ] [ -f ] [ -i index ] [ -m ] [ -r ] [ input ] DESCRIPTION
Archive makes copies of files specified on its standard input. It is normally run either as a channel feed under innd(8), or by a script before expire(8) is run. Archive reads the named input file, or standard input if no file is given. The input is taken as a set of lines. Blank lines and lines starting with a number sign (``#'') are ignored. All other lines should specify the name of a file to archive. If a filename is not an absolute pathname, it is taken to be relative to /var/spool/news. Files are copied to a directory within the archive directory, /var/spool/news/news.archive. The default is to create a hierarchy that mim- ics the input files; intermediate directories will be created as needed. For example, the input file comp/sources/unix/2211 (article 2211 in the newsgroup comp.sources.unix) will be copied to /var/spool/news/news.archive/comp/sources/unix/2211. OPTIONS
-a archive If the ``-a'' flag is used then its argument specifies the directory to archive in instead of the default. -f If the ``-f'' flag is used, then all directory names will be flattened out, replacing the slashes with periods. In this case, the file would be copied to /var/spool/news/news.archive/comp.sources.unix/2211. -i If the ``-i'' flag is used, then archive will append one line to the specified index file for each article that it copies. This line will contain the destination name and the Message-ID and Subject headers. -m Files are copied by making a link. If that fails a new file is created. If the ``-m'' flag is used, then the file will be copied to the destination, and the input file will be replaced with a symbolic link pointing to the new file. -r By default, archive sets its standard error to /var/log/news/errlog. To suppress this redirection, use the ``-r'' flag. EXIT STATUS
If the input is exhausted, archive will exit with a zero status. If an I/O error occures, it will try to spool its input, copying it to a file. If there was no input filename, the standard input will be copied to /var/spool/news/out.going/archive and the program will exit. If an input filename was given, a temporary file named input.bch (if input is an absolute pathname) or /var/spool/news/out.going/input.bch (if the filename does not begin with a slash) is created. Once the input is copied, archive will try to rename this temporary file to be the name of the input file, and then exit. EXAMPLES
A typical newsfeeds(5) entry to archive most source newsgroups is as follows: source-archive :!*,*sources*,!*wanted*,!*.d :Tc,Wn :/usr/lib/news/bin/archive -f -i /usr/spool/news/news.archive/INDEX HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.14, dated 1996/10/29. SEE ALSO
newsfeeds(5). ARCHIVE(8)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy