Sponsored Content
Top Forums Shell Programming and Scripting Append a field to the end of each line of a file based on searching another file. Post 67889 by vgersh99 on Tuesday 29th of March 2005 07:17:04 AM
Old 03-29-2005
nawk -f ult.awk FileB FileA

here's ult.awk:
Code:
BEGIN { FS=OFS="," }
FNR == NR { arr[$1]=$2; next }
{ $NF=($1 in arr) ? arr[$1] : "N.A."; print }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append to end of each line of file without a temp file.

Hello I am trying to append an incrimenting number to the end of each line I have it working with a temp file. But I want to do this without a temp file. a=1 cat "file" | while read LINE do echo "$LINE, $a" >> filewithnumbers a=`expr $a + 1` ... (4 Replies)
Discussion started by: rorey_breaker
4 Replies

2. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

3. Shell Programming and Scripting

append a character at end of each line of a file

Hi, i want to append a character '|' at end of each line of a file abc.txt. for example if the file abc.txt conatins: a|b|c 1|2|33 w|2|11 i want result file xyz.txt a|b|c| 1|2|33| w|2|11| I know this is simple but sumhow i am not able to reach end of line. its urgent, thanks for... (4 Replies)
Discussion started by: muaz
4 Replies

4. Shell Programming and Scripting

Line Count and Append it to the end of the file.

Hi, I want to get a Line count of a file and append that at the end of the file. The Line count should not include the Headers : ------------------ COL1,COL2,COL3 123,abc,011 111,abd,0212 Record Count: 2 ------------------- Thanks. (7 Replies)
Discussion started by: smc3
7 Replies

5. Shell Programming and Scripting

How can I append a string at the end of a line in a file

Hi, guys. I have one question: I have a file called "group", the contents of it is below: ******************************** ... test:x:203: sales:x:204: repair:x:205: research:x:206:brownj ... *********** Now I want to add string ",sherrys" at the end of "research:x:206:brownj", so... (5 Replies)
Discussion started by: daikeyang
5 Replies

6. Shell Programming and Scripting

Append a string at the end of every line in a file

Hi Friends, I have a file with many lines as shown below. /START SAMPLE LINE/ M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a M:\mmarimut_v6.4.0_pit_01\port\Post.java@@\main\v6.4.0_pit_a M:\mmarimut_v6.4.0_pit_01\switchview\View.java@@\main\v6.4.0_pit_a /END SAMPLE LINE/ I... (1 Reply)
Discussion started by: nmattam
1 Replies

7. Shell Programming and Scripting

Append the end of each line in a file with a given string

Hi friends, I have a file containing many lines as follows. M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a M:\mmarimut_v6.4.0_pit_01\ADBasicView.java@@\main\v6.4.0_pit_a I would like to append the string "\0" at the end of each line in the file. The output should look... (10 Replies)
Discussion started by: nmattam
10 Replies

8. Shell Programming and Scripting

Append text from one file to another based on a search from the end of a document

Hi all, I have output files that are all text files with various different extensions. So, if I submit the input file "job_name.inp", when it finishes I get an output file "job_name.dat". A typical input file looks something like this: $CONTRL SCFTYP=RHF RUNTYP=ENERGY MAXIT=199 MULT=1... (4 Replies)
Discussion started by: marcozd
4 Replies

9. Shell Programming and Scripting

SED and Solaris Append line to the end of File does not work

Hello, I have to add a new line at the end of a File on Solaris-System: I think my script should be right, because I evaluated it to other threads. However the script does not what I am expected it should do. My file might look like this: Line1 Line2 Line3 And my script could... (7 Replies)
Discussion started by: Timo_HR
7 Replies

10. Shell Programming and Scripting

To append new data at the end of each line based on substring of last column

Hi guys, I need to append new data at the end of each line of the files. This new data is based on substring (3rd fields) of last column. Input file xxx.csv: U1234|1-5X|orange|1-5X|Act|1-5X|0.1 /sac/orange 12345 0 U5678|1-7X|grape|1-7X|Act|1-7X|0.1 /sac/grape 5678 0... (5 Replies)
Discussion started by: null7
5 Replies
LIBXO(3)						   BSD Library Functions Manual 						  LIBXO(3)

NAME
xo_emit -- emit formatted output based on format string and arguments LIBRARY
library ``libxo'' SYNOPSIS
#include <libxo/xo.h> LIBXO(3) BSD Library Functions Manual LIBXO(3) NAME
xo_open_list xo_open_list_h xo_open_list_hd xo_open_list_d xo_open_instance xo_open_instance_h xo_open_instance_hd xo_open_instance_d xo_close_instance xo_close_instance_h xo_close_instance_hd xo_close_instance_d xo_close_list xo_close_list_h xo_close_list_hd xo_close_list_d -- open and close lists and instances LIBRARY
library ``libxo'' SYNOPSIS
int xo_open_list_h(xo_handle_t *xop, const char *name); int xo_open_list(const char *name); int xo_open_list_hd(xo_handle_t *xop, const char *name); int xo_open_list_d(const char *name); int xo_open_instance_h(xo_handle_t *xop, const char *name); int xo_open_instance(const char *name); int xo_open_instance_hd(xo_handle_t *xop, const char *name); int xo_open_instance_d(const char *name); int xo_close_instance_h(xo_handle_t *xop, const char *name); int xo_close_instance(const char *name); int xo_close_instance_hd(xo_handle_t *xop); int xo_close_instance_d(void); int xo_close_list_h(xo_handle_t *xop, const char *name); int xo_close_list(const char *name); int xo_close_list_hd(xo_handle_t *xop); int xo_close_list_d(void); DESCRIPTION
Lists are sequences of instances of homogeneous data objects. Two distinct levels of calls are needed to represent them in our output styles. Calls must be made to open and close a list, and for each instance of data in that list, calls must be make to open and close that instance. The name given to all calls must be identical, and it is strongly suggested that the name be singular, not plural, as a matter of style and usage expectations. A list is a set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close each instance of the list: xo_open_list("item"); for (ip = list; ip->i_title; ip++) { xo_open_instance("item"); xo_emit("{L:Item} '{:name/%s}':0, ip->i_title); xo_close_instance("item"); } xo_close_list("item"); Getting the list and instance calls correct is critical to the proper generation of XML and JSON data. EXAMPLE: xo_open_list("user"); for (i = 0; i < num_users; i++) { xo_open_instance("user"); xo_emit("{k:name}:{:uid/%u}:{:gid/%u}:{:home}0, pw[i].pw_name, pw[i].pw_uid, pw[i].pw_gid, pw[i].pw_dir); xo_close_instance("user"); } xo_close_list("user"); TEXT: phil:1001:1001:/home/phil pallavi:1002:1002:/home/pallavi XML: <user> <name>phil</name> <uid>1001</uid> <gid>1001</gid> <home>/home/phil</home> </user> <user> <name>pallavi</name> <uid>1002</uid> <gid>1002</gid> <home>/home/pallavi</home> </user> JSON: user: [ { "name": "phil", "uid": 1001, "gid": 1001, "home": "/home/phil", }, { "name": "pallavi", "uid": 1002, "gid": 1002, "home": "/home/pallavi", } ] LEAF LISTS
In contrast to a list of instances, a "leaf list" is list of simple values. To emit a leaf list, call the xo_emit() function using the ""l"" modifier: for (ip = list; ip->i_title; ip++) { xo_emit("{Lwc:Item}{l:item}0, ip->i_title); } The name of the field must match the name of the leaf list. In JSON, leaf lists are rendered as arrays of values. In XML, they are rendered as multiple leaf elements. JSON: "item": "hammer", "nail" XML: <item>hammer</item> <item>nail</item> ADDITIONAL DOCUMENTATION
Complete documentation can be found on github: http://juniper.github.io/libxo/libxo-manual.html libxo lives on github as: https://github.com/Juniper/libxo The latest release of libxo is available at: https://github.com/Juniper/libxo/releases SEE ALSO
xo_emit(3) HISTORY
The libxo library was added in FreeBSD 11.0. AUTHOR
Phil Shafer BSD
December 4, 2014 BSD
All times are GMT -4. The time now is 12:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy