Sponsored Content
Top Forums Shell Programming and Scripting awk (?) help or just general script Post 302319542 by devtakh on Monday 25th of May 2009 01:42:15 PM
Old 05-25-2009
Code:
awk 'FNR==NR{a[$1]=$2;next}NF <3{print $1,a[$1],$2}NF>2{print}' foo2 foo1


-Devaraj Takhellambam
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

General Question

Hi, I've been racking my brains trying to remember, but, whats the command to change the default shell? I'm currently always in the Korn shell and I want to start out in the Bash shell. I'm running a variant of BSD I guess in Mac OS X 10.2.2 and Mandrake. Thanks. ccindyderek:confused: (4 Replies)
Discussion started by: ccindyderek
4 Replies

2. Shell Programming and Scripting

general question?

Perl, Python, and PHP are these languages easy to use? Are they command line or are they part of a GUI? (2 Replies)
Discussion started by: wmosley2
2 Replies

3. UNIX for Dummies Questions & Answers

General Query

Hi all My job is to bootup the servers (1 sun solaris 5.8, 3 sco (release 5) and 1 windows 2000), taking backup of the servers and shut down. Apart from this, there are nearly 150 users for our oracle9i database (forms 3 and d2k as front end). As for as oracle 9i is concerned my job is to... (0 Replies)
Discussion started by: raguramtgr
0 Replies

4. Shell Programming and Scripting

General question about the relationship between KSH and sed/grep/awk etc

Greetings all, Unix rookie here, just diving into ksh scripting for the first time. My question may seem confusing but please bear with me: If I'm understanding everything I'm reading properly, it seems like the ksh language itself doesn't have a lot of string manipulation functions of... (2 Replies)
Discussion started by: DalTXColtsFan
2 Replies

5. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

6. UNIX for Dummies Questions & Answers

If statements/general help

Dear Unix community over the last couple of days I have been working on learning Unix scripting on iOS using terminal on a jail-broken device... I am having trouble with if statements and giving the user a y or n choice that do different things when entered. The following is my code so far...... (5 Replies)
Discussion started by: mbf123
5 Replies

7. UNIX for Dummies Questions & Answers

awk gsub(): general regex

%%%%% (9 Replies)
Discussion started by: lucasvs
9 Replies

8. UNIX for Beginners Questions & Answers

General Purpose Date Script

There must be thousands of one-off solutions scattered around this forum. GNU Date is so handy because it's general but if they're asking they probably don't have it. We have some nice scripts but they tend to need dates formatted in a very particular way. This is a rough approximation which... (18 Replies)
Discussion started by: Corona688
18 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 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy