Sponsored Content
Full Discussion: Bring two files together
Top Forums Shell Programming and Scripting Bring two files together Post 302960106 by Aia on Tuesday 10th of November 2015 04:45:06 PM
Old 11-10-2015
Quote:
Originally Posted by RudiC
The requestor seemed to want to eliminate the records not in the head file. So try a small adaption to Aia's code:
Code:
awk 'FNR==NR {h["+" $1]=$2;next} $1 in h {print $0, h[$1]; getline; print}' head text
[...]

Based on the title of the post and on the following opening sentence:
Quote:
I was wondering if anybody could help me to bring [two] files together.
I took it as the opposite, even when I did not see any output for text_D or text_E

Nevertheless, for that case I would suggest:
Code:
awk 'FNR==NR {h[$1]=$2;next} $1 in h {print "+" $1, h[$1];print $2}' head.file RS="+" text.file

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bring back removed files

Dear People I have removed some of my files and directories( by using rm and rmdir commands) by mistake. I wish to bring them back. How is it possible?( I am using solaris 2.6) best regards Reza Nazarian:( (2 Replies)
Discussion started by: Reza Nazarian
2 Replies

2. IP Networking

unable to bring up any interface

I have Linux 7.1 setup on a Dell and am unable to bring up any interfaces. Both the lo and eth0 fail upon boot up and I get a insmod error possibly due to bad irq or IO setting. If I disable eth0 upon boot, then lo works fine, but offcourse I get the "delaying initialization" upon boot for eth0... (1 Reply)
Discussion started by: alam
1 Replies

3. Solaris

bring up GUI on solaris

I have just installed solaris 10 on a sever .would appreciate if somebody can help me bringing up the GUI(basically i want to launch the browser) (1 Reply)
Discussion started by: Anant
1 Replies

4. UNIX for Dummies Questions & Answers

Unable to bring up Sun OS

The last thing I did was set REMOTE_LOGIN_PASSWORDFILE to EXCLUSIVE. Then rebooted server. Since that time I have not been able to login. During bootup it can't find root and generates alot of errors. Does anybody know of a default login and password that will allow me to log in and rebuild the... (2 Replies)
Discussion started by: mayewil
2 Replies

5. Solaris

Not able to bring up the server

Hi All, I have a iplanet server running on solaris , i'm not able to start it using the start Its giving following error root@bld00: /usr/iplanet/servers6.1sp8/https-MLL-8.3dev # ./start Sun ONE Web Server 6.1SP8 B06/13/2007 23:15 info: CORE5076: Using from info: WEB0100: Loading web... (2 Replies)
Discussion started by: renjithrnath
2 Replies

6. Red Hat

Cannot bring up Firefox

I have installed firefox and it previously worked before I installed the oracle software on my machine. Now when I click on the icon to bring up the browser it fails. I tried to do it from the command line and this is what I get: $ firefox Cannot find mozilla runtime directory. Exiting ... (1 Reply)
Discussion started by: jxh461
1 Replies

7. UNIX for Dummies Questions & Answers

bring up/down numerous interfaces

On a Solaris 9 system I had something happen to some of my interfaces; for some reason half of them went down. Since I have over 30 different Virtual IP's (or logical IP's) up on ce10 I don't want to take the time to find out which ones are up and which ones are down or even run the addif command... (2 Replies)
Discussion started by: snoman1
2 Replies

8. HP-UX

Adding Storage, do I need to bring the DB down?

Hi Guys, Do I need to bring the DB down? masd023x:: uname -r B.11.11 Thanks! Where can I find this type of information? JC (3 Replies)
Discussion started by: 300zxmuro
3 Replies

9. Shell Programming and Scripting

Bring prompt from a different process

Hi, while running a program one of the command is creating a sub-shell which requires user inputs. Is there a way to bring the input prompt to a parallel session or an alternate way to input the values? the outer program doesn't allow to accept the parameter value for the command run in the sub... (8 Replies)
Discussion started by: ahmedwaseem2000
8 Replies
SHELL-QUOTE(1)						User Contributed Perl Documentation					    SHELL-QUOTE(1)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.16.3 2010-06-11 SHELL-QUOTE(1)
All times are GMT -4. The time now is 01:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy