merge ldif files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merge ldif files
# 1  
Old 11-23-2009
merge ldif files

Hi,

I'd like to merge several ldif files into one. however simple cat *.ldif >> all.ldif is not working ( the data content is not sequential ), and also "more *.ldif > all.ldif" adds file names. I'd like all.ldif to be

all.ldif

content of 1.ldif
content of 2.ldif
-
-


Also, i came through this thread but the script doesn't work.

https://www.unix.com/shell-programmin...rge-files.html

code
#!/bin/sh
echo enter file name
read f
echo enter number of such files
read n
i=1
while test $i -ne $n
do
echo $f$i >> outfile
cat $f$i >> outfile
i=`expr $i + 1`
done

Can anyone help me to do this.

Thanks in Advance.

Regards, John
# 2  
Old 11-23-2009
Perhaps this will work?
Code:
ls *.ldif|sort -n|xargs cat > ldif.out

# 3  
Old 11-23-2009
Thanks it works, but i would like to segregate the content with a blank line.

How can i do that?
# 4  
Old 11-23-2009
Like this for instance:
Code:
ls *.ldif|sort -n| 
while read file; do
  cat $file
  echo
done> ldif.out

# 5  
Old 11-23-2009
Yep, it works ..thanks a lot !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Code to convert LDIF to CSV

Team , I am new to perl. Can someone help me out to convert LDIF file to csv format using perl logic ? LDIF file format contains values : ID : name/Bose-IND/ORD,cu-150,ou=ends Connection_Time: 02:12:54 EST LDAP: yes Link: ABC Home Page - ABC.com Expected outcome should with column... (0 Replies)
Discussion started by: Perlbaby
0 Replies

2. Shell Programming and Scripting

LDIF Data sorting by timestamp

I am a newbie and need awk or sed script to run against LDIF format data and sort by create time stamp (2 Replies)
Discussion started by: atlowi
2 Replies

3. Shell Programming and Scripting

Merge files and generate a resume in two files

Dear Gents, Please I need your help... I need small script :) to do the following. I have a thousand of files in a folder produced daily. I need first to merge all files called. txt (0009.txt, 0010.txt, 0011.txt) and and to output a resume of all information on 2 separate files in csv... (14 Replies)
Discussion started by: jiam912
14 Replies

4. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

5. Shell Programming and Scripting

merge two different files

HI I have input file as date 22jan2011 calc 0 667788.1 998877.2 vals 1 222 444 666 777 999 vals 2 222 444 666 777 999 vals 3 ... (3 Replies)
Discussion started by: Indra2011
3 Replies

6. Shell Programming and Scripting

Merge files

Hello, I have a application software plink. It can merge files with some kinds of way. The command likes: plink --file 1 --merge 2 --recode --out merged That means merge file 1 and 2 then output file "merged". However I have 23 files (1,2,3,...22,23)to be merged together. How can I use... (2 Replies)
Discussion started by: zhshqzyc
2 Replies

7. Shell Programming and Scripting

How can i merge these two files into several...

Given are File A and File B File A has for example 5 lines: AAA BBB CCC DDD EEE File B has 3 lines: 111 222 333 How can i merge A and B into: 111 222 333 AAA (first line from A) then a new file: (4 Replies)
Discussion started by: Y-T
4 Replies

8. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

9. Shell Programming and Scripting

shell scripts to grep dn in ldif file

Hi gurus out there, 1)I am using ksh, in solaris 10. 2)I have one ldif file, I need to output user DN with attributes=<some pattern> to a file. Example: dn: uid=joy,ou=People,o=abc.com,o=isp nswmExtendedUserPrefs: meAutoSign=true nswmExtendedUserPrefs: meSignature=Regards, Joy... (3 Replies)
Discussion started by: bulkbiz
3 Replies

10. Shell Programming and Scripting

how to merge these two files?

I have two files, each of them has 12 lines, fileA has 3 columns, fileB has 1 column, like the following FileA a 1 b 2 c 3 ..blabla FileB A B C ..blabla Now I am trying to put the content of fileB as column 3 of fileA, e.g. a 1 A b 2 B c 3 C (3 Replies)
Discussion started by: fedora
3 Replies
Login or Register to Ask a Question