Sponsored Content
Top Forums Shell Programming and Scripting Pick a line in file 2 basing on array in file1 Post 302856617 by nksharma74 on Tuesday 24th of September 2013 10:43:09 AM
Old 09-24-2013
not sure why you want to use awk but you could simply use join.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a binary file into 2 basing on 2 delemiter string

Hi all, I have a binary file (orig.dat) and two special delimiter strings 'AAA' and 'BBB'. My binary file's content is as follow: <Data1.1>AAA<Data1.2>BBB <Data2.1>AAA<Data2.2>BBB ... <DataN.1>AAA<DataN.2>BBB DataX.Y might have any length, and contains any kind of special/printable... (1 Reply)
Discussion started by: Averell
1 Replies

2. Shell Programming and Scripting

cat file1 read line-per-line then grep -A 15 lines down in fileb

STEP 1 # Set variable FILE=/tmp/mainfile SEARCHFILE =/tmp/searchfile # THIS IS THE MAIN FILE. cat /tmp/mainfile Interface Ethernet0/0 "outside", is up, line protocol is up Hardware is i82546GB rev03, BW 100 Mbps Full-Duplex(Full-duplex), 100 Mbps(100 Mbps) MAC address... (6 Replies)
Discussion started by: irongeekio
6 Replies

3. Shell Programming and Scripting

Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies

4. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies

5. Shell Programming and Scripting

Split a single file into several others basing on the last column

Hi folks, Happy new year. I have a file 'filename' that i wd like to split basing on the contents in the last column. The 'filename' content looks like 256772744788,9,11 256772744805,9,11 256772744792,9,11 256775543055,10,12 256782625357,9,12 256772368953,10,13 256772627735,10,13... (3 Replies)
Discussion started by: jerkesler
3 Replies

6. UNIX Desktop Questions & Answers

awk to pick out more than one line

This really is a dummy question but I'm stuck and out of time... I have a large file and out of it I only want to pick out lines starting with either "Pressure" or "N". I still need these lines to be in their original order. example of text Pressure 3 N 2 N 3 bla bla bla bla Pressure 4... (3 Replies)
Discussion started by: jenjen_mt
3 Replies

7. Shell Programming and Scripting

Replacing line 'i' of file1 with line 'j' of file 2

Hi All, As mentioned in the title I have two text files and I would like to replace line number 5 of file #1 with line number 4 of file #2 e.g. file 1 wqwert 4.4464002 3 319 286 369 46.320002 56.150002 45.100002 1 1 1 0.723 (12 Replies)
Discussion started by: f_o_555
12 Replies

8. Shell Programming and Scripting

Pick a card from an array in bash

Hello, I am trying to use $RANDOM to pick cards from an array in bash. I created the script below to give me a selection everytime I run it, but the output is always like this: 2 3 4 5 6 7 8 9 10 Jack Queen King Ace of Clubs Diamonds Hearts Spades. Can you please help me? I expected it to... (2 Replies)
Discussion started by: Pouchie1
2 Replies

9. Shell Programming and Scripting

Using regex's from file1, print line and line after matches in file2

Good day, I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after. file1: file2: Output: I can match a regex and print the line and line after awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } ' ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

10. UNIX for Dummies Questions & Answers

Deleting file basing on the timestamp substring in the file name

Hello, I have in my backup folder, files with names convention like this : randomFileNames_13-02-2014_23h13m09+1392333189 randomFileNames_14-02-2014_02h13m09+1392343989 randomFileNames_14-02-2014_04h13m09+1392351189 etc.... Base on timestamp at end of the filename, I would to delete all the... (7 Replies)
Discussion started by: thuyetti
7 Replies
getgroups(2)							   System Calls 						      getgroups(2)

NAME
getgroups, setgroups - get or set supplementary group access list IDs SYNOPSIS
#include <unistd.h> int getgroups(int gidsetsize, gid_t *grouplist); int setgroups(int ngroups, const gid_t *grouplist); DESCRIPTION
The getgroups() function gets the current supplemental group access list of the calling process and stores the result in the array of group IDs specified by grouplist. This array has gidsetsize entries and must be large enough to contain the entire list. This list cannot be larger than NGROUPS_UMAX. If gidsetsize equals 0, getgroups() will return the number of groups to which the calling process belongs without modifying the array pointed to by grouplist. The setgroups() function sets the supplementary group access list of the calling process from the array of group IDs specified by grou- plist. The number of entries is specified by ngroups and can not be greater than NGROUPS_MAX. RETURN VALUES
Upon successful completion, getgroups() returns the number of supplementary group IDs set for the calling process and setgroups() returns 0. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The getgroups() and setgroups() functions will fail if: EFAULT A referenced part of the array pointed to by grouplist is an illegal address. The getgroups() function will fail if: EINVAL The value of gidsetsize is non-zero and less than the number of supplementary group IDs set for the calling process. The setgroups() function will fail if: EINVAL The value of ngroups is greater than {NGROUPS_MAX}. EPERM The {PRIV_PROC_SETID} privilege is not asserted in the effective set of the calling process. USAGE
Use of the setgroups() function requires the {PRIV_PROC_SETID} privilege. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |getgroups() is Standard. | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
groups(1), chown(2), getuid(2), setuid(2), getgrnam(3C), initgroups(3C), attributes(5), privileges(5), standards(5) SunOS 5.11 8 Sep 2006 getgroups(2)
All times are GMT -4. The time now is 06:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy