Sponsored Content
Full Discussion: input -output file
Top Forums Shell Programming and Scripting input -output file Post 302321386 by hegdeshashi on Monday 1st of June 2009 03:08:06 AM
Old 06-01-2009
Hi

here is my program..

=========

for record in `cat eamcs.txt`
do

user=`echo $record | awk -F, '{print $1}'`

ldapsearch -h ldap uid="$user" uid ou eriMasterDomain eriCountry | \
egrep "^ou=|^eriMasterDomain=|^uid=|^eriCountry=" | \
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{prin
t $1 " "}}' >> output.txt
done

================

here is my input
===============
ERTCHWE
ERTSYWU
ERTKESU
ERTSEYU
ERTWSY
EILRAAL


===========
out put is coming like this..
======

uid=ERTCHWE | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=ERTSYWU | eriCountry=Taiwan, | ou=ERT | uid=ERTKESU | eriMasterDomain=EAPAC
| eriCountry=Taiwan, | ou=ERT
uid=ERTSEYU | ou=ERT |uid=ERTWSY | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=EILRAAL | eriMasterDomain=EAPAC | eriCountry=India | ou=EIL
==============

But, I want like this=====>

uid=ERTCHWE | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=ERTSYWU | eriCountry=Taiwan, | ou=ERT
uid=ERTKESU | eriMasterDomain=EAPAC| eriCountry=Taiwan, | ou=ERT
uid=ERTSEYU | ou=ERT
uid=ERTWSY | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=EILRAAL | eriMasterDomain=EAPAC | eriCountry=India | ou=EIL

=======

thanks in advance..

-----Post Update-----

Hi friends,

the problem is in line....
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{prin
t $1 " "}}' >> output.txt


here it counts upto 4 ,if it is less then it writes..

could you please correct as it has to check uid..if uid fails, thencome out of loop...
am I right ?


thanks

-----Post Update-----

Hi friends,

the problem is in line....
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{prin
t $1 " "}}' >> output.txt


here it counts upto 4 ,if it is less then it writes..

could you please correct as it has to check uid..if uid fails, thencome out of loop...
am I right ?


thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

2. Shell Programming and Scripting

AWK Script to convert input file(s) to output file

Hi All, I am hoping someone can help me with some scripting I need to complete using AWK. I'm trying to process multiple fixed files to generate one concatenated fixed file in a standard format. The Input file is:- aaaa bbbbb ccccc 1 xxxx aaa bbb aaaa bbbbb ccccc 2 abcd aaa CCC... (9 Replies)
Discussion started by: jason_v_brown
9 Replies

3. Shell Programming and Scripting

split input data file and put into same output file

Hi All, I have two input file and need to generate a CSV file. The existing report just "GREP" the records with the Header and Tailer records with the count of records. Now i need to split the data into 25 records each in the same CSV file. id_file (Input file ) 227050994 232510151... (4 Replies)
Discussion started by: rasmith
4 Replies

4. UNIX for Dummies Questions & Answers

12. If an ‘88’ Record with BAI Code ‘902’ was found on input file and not written to Output file, re

This is my input file like this 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/ 49,+00000000000416920,00002/ 03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/ 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/ 88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies

5. Shell Programming and Scripting

input a file editing it, output it.

i have a file that contains such earthquake data, i want to write an AWK or SED script to input it and fix it (delete each section header delete some field, delete some blank lines and put ### instead of that) and at the end output it to a new file. here is my file: EventID Date (UTC)... (2 Replies)
Discussion started by: oreka18
2 Replies

6. Homework & Coursework Questions

Loop to Convert a list from an input file and output it to another file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A) Write a script, which will take input from a file and convert the number from Centigrade to Fahrenheit... (5 Replies)
Discussion started by: AliTheSnake
5 Replies

7. Shell Programming and Scripting

Input file is uncolored; I want the output file to be colored on criteria

Hello, I have the following input file: auditing account: 3DTP (3dtp) ERROR: S3 bucket "aws-origin-test1.3dstage.com" has policy statement with public grant: {"Sid":"PublicReadGetObject","Effect":"Allow","Principal":{"AWS":"*"},"Action":,"Resource":} auditing region: eu-west-1 auditing... (5 Replies)
Discussion started by: ramky79
5 Replies

8. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

9. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Programming

creating separate output file for each input file in python

Experts, Need your help for this. Please support My motive is to create seperate output file for each Input Files(File 1 and File2) in another folder say(/tmp/finaloutput) Input files File 1(1.1.1.1.csv) a,b,c 43,17104773,3 45,17104234,4 File 2(2.2.2.2.csv) a,b,c 43,17104773,1... (2 Replies)
Discussion started by: as7951
2 Replies
CRMGR(1)						      Quick Database Manager							  CRMGR(1)

NAME
crmgr - administration utility for QDBM Curia SYNOPSIS
crmgr create [-s] [-bnum num ] [-dnum num] name crmgr put [-kx|-ki] [-vx|-vi|-vf] [-keep|-cat] [-lob] [-na] name key val crmgr out [-kx|-ki] [-lob] name key crmgr get [-nl] [-kx|-ki] [-start num] [-max num] [-ox] [-lob] [-n] name key crmgr list [-nl] [-k|-v] [-ox] name crmgr optimize [-bnum num] [-na] name crmgr inform [-nl] name crmgr remove name crmgr repair name crmgr exportdb name dir crmgr importdb name dir crmgr snaffle [-kx|-ki] [-ox] [-n] name key crmgr version DESCRIPTION
This manual page documents briefly the crmgr commands. crmgr is a utility for debugging Curia and its applications. It features editing and checking of a database. It can be used for the data- base applications with shell scripts. This command is used in the above format. name specifies a database name. key specifies the key of a record. val specifies the value of a record. OPTIONS
A summary of options is included below. For a complete description, see the file:///usr/share/doc/qdbm-doc/spex.html#curiacli. -s make the file sparse. -bnum num specify the number of the elements of the bucket array. -dnum num specify the number of division of the database. -kx treat key as a binary expression of hexadecimal notation. -ki treat key as an integer expression of decimal notation. -vx treat val as a binary expression of hexadecimal notation. -vi treat val as an integer expression of decimal notation. -vf read the value from a file specified with val. -keep specify the storing mode for `CR_DKEEP'. -cat specify the storing mode for `CR_DCAT'. -na do not set alignment. -nl open the database without file locking. -start specify the beginning offset of a value to fetch. -max specify the max size of a value to fetch. -ox treat the output as a binary expression of hexadecimal notation. -lob handle large objects. -n do not output the tailing newline. -k output keys only. -v output values only. SEE ALSO
qdbm(3), crtsv(1), curia(3), cropen(3). AUTHOR
QDBM was written by Mikio Hirabayashi <mikio@fallabs.com>. This manual page was written by Fumitoshi UKAI <ukai@debian.or.jp>, for the Debian project (but may be used by others). Man Page 2005-05-23 CRMGR(1)
All times are GMT -4. The time now is 11:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy