Sponsored Content
Top Forums Shell Programming and Scripting Reading specific contents from 1 input files and appending it to another input file Post 302227604 by sksahu on Thursday 21st of August 2008 03:18:22 PM
Old 08-21-2008
Franklin52 - Thanks for your help. One more question though, If I have another input file

Input file 3
XYZ,Desc1
VZG,Desc2

And if I would like to add more to output file by looking into input file 3, then how would I get the "XYZ" to get the description from input file 3.

Output file
Desc1,Aug 14 10:37 123.XYZ.106.20061023160210.in, EFGH
Desc1,Aug 14 12:59 135.XYZ.107.20061023160210.in, RTYT
Desc1,Aug 14 13:15 234.XYZ.108.20061023160210.in, GHJK

I tried this but no luck

awk -F",| |\\\.\." 'NR==FNR{a[$1]=$2;next}
$4 in a{print $0 "," a[$4]}
' file3 file1

Appreciate your responses.

Last edited by sksahu; 01-13-2009 at 03:48 PM..
 

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
term::ansi::ctrl::unix(n)					 Terminal control					 term::ansi::ctrl::unix(n)

__________________________________________________________________________________________________________________________________________________

NAME
term::ansi::ctrl::unix - Control operations and queries SYNOPSIS
package require Tcl 8.4 package require term::ansi::ctrl::unix ?0.1? ::term::ansi::ctrl::unix::import ?ns? ?arg...? ::term::ansi::ctrl::unix::raw ::term::ansi::ctrl::unix::raw ::term::ansi::ctrl::unix::columns ::term::ansi::ctrl::unix::rows _________________________________________________________________ DESCRIPTION
WARNING: This package is unix-specific and depends on the availability of two unix system commands for terminal control, i.e. stty and tput, both of which have to be found in the $PATH. If any of these two commands is missing the loading of the package will fail. The package provides commands to switch the standard input of the current process between raw and cooked input modes, and to query the size of terminals, i.e. the available number of columns and lines. API
INTROSPECTION ::term::ansi::ctrl::unix::import ?ns? ?arg...? This command imports some or all attribute commands into the namespace ns. This is by default the namespace ctrl. Note that this is relative namespace name, placing the imported command into a child of the current namespace. By default all commands are imported, this can howver be restricted by listing the names of the wanted commands after the namespace argument. OPERATIONS ::term::ansi::ctrl::unix::raw This command switches the standard input of the current process to raw input mode. This means that from then on all characters typed by the user are immediately reported to the application instead of waiting in the OS buffer until the Enter/Return key is received. ::term::ansi::ctrl::unix::raw This command switches the standard input of the current process to cooked input mode. This means that from then on all characters typed by the user are kept in OS buffers for editing until the Enter/Return key is received. ::term::ansi::ctrl::unix::columns This command queries the terminal connected to the standard input for the number of columns available for display. ::term::ansi::ctrl::unix::rows This command queries the terminal connected to the standard input for the number of rows (aka lines) available for display. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category term of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
ansi, columns, control, cooked, input mode, lines, raw, rows, terminal CATEGORY
Terminal control COPYRIGHT
Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net> term 0.1 term::ansi::ctrl::unix(n)
All times are GMT -4. The time now is 01:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy