Sponsored Content
Top Forums Shell Programming and Scripting Reading from one file and updating other file with constant entries Post 302498862 by bartus11 on Tuesday 22nd of February 2011 05:14:25 PM
Old 02-22-2011
Assuming there are no spaces between records in first file, like here:
Code:
A:
uid: 1111
C:
D:
E:
 <====== there should be no space here for this code to work!!
A:
uid: 2222
C:
D:
E:

Code:
awk -vRS= -vORS="\n\n" -vFS="\n" 'NR==FNR{for (i=1;i<=NF;i++){a[$i]}next}$2 in a{print $0"\nnsrole: cn=nsdisabledrole,dc=wwww,dc=cccc,dc=com\nnsrole: cn=nsmanageddisabledrole,dc=wwww,dc=cccc,dc=com\nnsaccountlock: true";next}1' file2 file1

 

10 More Discussions You Might Find Interesting

1. Programming

File descriptor constant

I have a requirement to close all the file descriptors from 3 to 1024 for a particular application. Right now, this is how I do it .. for ( int i = 3 ; i <= 1024; ++i ) close(i); The change I am looking at is, I want to do away with the number 1024 and replace it with a constant which... (4 Replies)
Discussion started by: vino
4 Replies

2. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

3. UNIX for Dummies Questions & Answers

Updating a field in a File without creating temp file's

Hi Experts, I have a requirement where i need to update the below items in file, 1. END TIME 2. PREV_STATUS For the first time the PREV_status and end time of all job the job will be sysdate & NULL reply as below, Session_name,Load Type,Frequency,Seesion End time,Prev_Status... (2 Replies)
Discussion started by: prabhutkl
2 Replies

4. Shell Programming and Scripting

how I can add a constant to a field without changing the file format

Hi, I need to edit a file Protein Data Bank (pdb) and then open that file with the program VMD but when I edit the file with awk, it changes pdb format and the VMD program can not read it. I need to subtract 34 to field 6 ($ 6). this is a pdb file : ATOM 918 N GLY B 103 -11.855 8.675... (8 Replies)
Discussion started by: bio_
8 Replies

5. Shell Programming and Scripting

Help with reading file with values and updating another file

Hi I need some help with a task, i am an absolute newbie to any form of shell scripting and request guidance. Task: 1. Read a config file in form of name value pair ex host=www.test.com port=8080 binding="dynamic" or "other" or "something else" key1=value1 key2=value2 key3=value4... (4 Replies)
Discussion started by: mk7074
4 Replies

6. Shell Programming and Scripting

reading and updating property file

I have to do a read operation for a field in property file, which looks like follows: 123|xyz|datetime|count '|' is delimiter. Finally I managed to read the contents of property file using statement like cut -d"|" -f1 $PROPERTIES_FILE | tr '\n' ' ' <-- Reading first column But now I... (2 Replies)
Discussion started by: rakeshranjanscs
2 Replies

7. Programming

[Makefile]File + constant problem

Hi guys, I am writing a Makefile with some strange features. What I have is: list of files *.efi list of guids (guid is just a number) one *.efi file is supposed to be used with one guid, so efi file and guid is a pair. What I need is: list of files *.fv How to make *.fv file... (1 Reply)
Discussion started by: Chrisdot
1 Replies

8. Shell Programming and Scripting

awk for splitting file in constant chunks

Hi gurus, I wanted to split main file in 20 files with 2500 lines in each file. My main file conatins total 2500*20 lines. Following awk I made, but it is breaking with error. awk '{ for (i = 1; i <= 20; i++) { starts=2500*$i-1; ends=2500*$i; NR>=starts && NR<=ends {f=My$i".txt"; print >> f;... (10 Replies)
Discussion started by: mukesh.lalwani
10 Replies

9. Shell Programming and Scripting

Need to insert text(constant) at the beginning of file

I am very new to scripting and I know this request is simple but I am having no luck with it. I have a file a.dat with the following data in it. aa bb cc dd I need to run a script that will take each line of a.dat and put dsjc/ubin/ in front of each record, so the output looks like ... (2 Replies)
Discussion started by: jclanc8
2 Replies

10. Shell Programming and Scripting

Howto add a constant column to the text file

Hi, I am converting a .DBF file to pipe delimited file my requirement is like lets say my .DBF is residing in path /a/b/c/d/f/abc.DBF I need my .txt file as having a column with source _cd =f sample data in .DBF in folder "f" c1 c2 c3 1 2 3 in txt file it should be... (4 Replies)
Discussion started by: angel12345
4 Replies
DO_SETRESUID(9) 					   BSD Kernel Developer's Manual					   DO_SETRESUID(9)

NAME
do_setresuid, do_setresgid -- set process uid and gid SYNOPSIS
#include <sys/ucred.h> int do_setresuid(struct lwp *lwp, uid_t ruid, uid_t euid, uid_t svuid, u_int flags); int do_setresgid(struct lwp *lwp, uid_t ruid, uid_t euid, uid_t svuid, u_int flags); DESCRIPTION
The do_setresuid and do_setresgid functions are used to implement the various system calls that allow a process to change its real, effec- tive, and saved uid and gid values. The do_setresuid function sets the specified processes real user ID to ruid, its effective user ID to euid, and its saved user ID to svuid. If any of the uid arguments are -1 then that assignment is skipped. If suser() is true, then any values may be assigned, otherwise the new uid values must match one of the existing values and the caller must have set the relevant bit in flags. The flags argument specifies which of the existing uid values the new value must match. It should be set to a logical OR of ID_{R,E,S}_EQ_{R,E,S}, where ID_E_EQ_R means that it is valid to set the effective ID to the current value of the real ID. The do_setresgid function sets the group IDs but otherwise behaves in the same manner as do_setresuid. The processes group list is neither examined nor effected. SEE ALSO
setregid(2), setreuid(2), setuid(2), suser(9) CODE REFERENCES
These functions are implemented in: sys/kern/kern_prot.c. HISTORY
Implemented for NetBSD 2.0 to replace ad-hoc code in each system call routine and in the various compat modules. BSD
September 28, 2003 BSD
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy