Sponsored Content
Full Discussion: Awk solution
Top Forums Shell Programming and Scripting Awk solution Post 302406378 by TonyFullerMalv on Monday 22nd of March 2010 05:51:57 PM
Old 03-22-2010
Does it have to be in awk(1)?

Here is a shell script that would do the trick:
Code:
$ cat file_order_number_test.sh
#!/bin/bash
while read ORDERNUMBER; do
  grep "^${ORDERNUMBER}" file1-order-data-file
done < file2-order-numbers
$

Here are example data files:
Code:
$ cat file1-order-data-file 
number, cust., part, qty, date 
0001, BAE Systems, wing, 1, 20th Dec. 2000
0002, BA, In Flight Lunches, 20, 21st Dec. 2000
0003, Boots The Chemist, Aspirin 500mg, 1000, 22nd Dec. 2000
0004, Cadbury, Full Fat Milk, 10000, 23rd Dec. 2000
0005, Woolworths, A4 Photocopy Paper, 144, 27th Dec. 2000
0006, Marks and Spencer, Cotton Y-Fronts, 2000, 28th Dec. 2000
0007, Goldburg Jewellers, Gold Bullion, 10, 29th Dec. 2000
$

Code:
$ cat file2-order-numbers 
0001
0003
0005
0007

Here is a test run:
Code:
$ ./file_order_number_test.sh
0001, BAE Systems, wing, 1, 20th Dec. 2000
0003, Boots The Chemist, Aspirin 500mg, 1000, 22nd Dec. 2000
0005, Woolworths, A4 Photocopy Paper, 144, 27th Dec. 2000
0007, Goldburg Jewellers, Gold Bullion, 10, 29th Dec. 2000

Is that any good to you?
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is there a awk solution for this??

I am writing a awk script that gathers certain data from certain fields. I needed a awk solution for this, because it will later become a function in the script. I have the following data that I need output on a single line, but record spans across multilple lines and records are not... (7 Replies)
Discussion started by: timj123
7 Replies

2. Shell Programming and Scripting

AWK or SED solution

Hello. I have big file data like this(part of file): .... 18210102021010000110 47401000000 021001 5166891.16 021011 5166891.16 18210602010020000110 47401000000 020701 8995421.00 021001 8995421.00 021011 8995421.00 030801 .08 18210604011020000110 47401000000 020701 9048.00 021001... (3 Replies)
Discussion started by: maxoff
3 Replies

3. Shell Programming and Scripting

Any solution with awk for volatile columns??

Hi I have this file with content ale,4 ,ale,2 ,ale,1 ,ale,2 ale,1 ,ale,7 ,ale,7 ,ale,13 ale,6 ,ale,1 ,ale,1 ,ale,1 ale,1 ,ale,1 ,ale,37 ,ale,1 ale,1 ,ale,1 ,ale,2 ,ale,37 ale,77 ,ale,1 ,ale,53 ,ale,3 ale,5 ,ale,1 ,ale,2 ,ale,40 ale,1 ,ale,1 ,ale,44 ,ale,1... (7 Replies)
Discussion started by: nikhil jain
7 Replies

4. Shell Programming and Scripting

sed or awk Solution

Hi I am having a csv file like this ahsh,90.82,add,32424,ahha hhdh,98.89,hdhdh,92728,neha hshs,you,97.7,hdhdhd,are,a jsjsj,wonderful,9788,79.9,aheh ahdh,95.5,girl, 2737,jolllI need to add width="100" to the value which is greater than 90 like decimal points but less than 100 Output... (5 Replies)
Discussion started by: kshitij
5 Replies

5. UNIX for Dummies Questions & Answers

Help with awk solution to add columns

Hi all. Wondering if someone can help with an awk solution to a problem I'm stumped with. I have a matrix file with >1000 fields and would like to add another column after each column with a text label. For example: Input: $cat file.txt name col1 col2 col3 coln aaaa ... (2 Replies)
Discussion started by: torchij
2 Replies

6. UNIX for Beginners Questions & Answers

awk solution for Splitting a file.

Hi I have a csv file with as below sdg-catalog-00000001 sdg-sku-00000317 sdg-sku-00000318 sdg-sku-00000319 sdg-sku-00000320 sdg-catalog-00000002 sdg-sku-00000321 sdg-sku-00000322 sdg-sku-00000323 sdg-sku-00000324 sdg-sku-00000325 sdg-catalog-00000003 sdg-sku-00000326... (3 Replies)
Discussion started by: Raghuram717
3 Replies
XZDIFF(1)							     XZ Utils								 XZDIFF(1)

NAME
xzcmp, xzdiff, lzcmp, lzdiff - compare compressed files SYNOPSIS
xzcmp [cmp_options] file1 [file2] xzdiff [diff_options] file1 [file2] lzcmp [cmp_options] file1 [file2] lzdiff [diff_options] file1 [file2] DESCRIPTION
xzcmp and xzdiff invoke cmp(1) or diff(1) on files compressed with xz(1), lzma(1), gzip(1), or bzip2(1). All options specified are passed directly to cmp(1) or diff(1). If only one file is specified, then the files compared are file1 (which must have a suffix of a supported compression format) and file1 from which the compression format suffix has been stripped. If two files are specified, then they are uncom- pressed if necessary and fed to cmp(1) or diff(1). The exit status from cmp(1) or diff(1) is preserved. The names lzcmp and lzdiff are provided for backward compatibility with LZMA Utils. SEE ALSO
cmp(1), diff(1), xz(1), gzip(1), bzip2(1), zdiff(1) BUGS
Messages from the cmp(1) or diff(1) programs refer to temporary filenames instead of those specified. Tukaani 2010-09-27 XZDIFF(1)
All times are GMT -4. The time now is 09:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy