Sponsored Content
Top Forums Shell Programming and Scripting Creating duplicate records from a single line Post 302912201 by junior-helper on Wednesday 6th of August 2014 01:05:06 PM
Old 08-06-2014
Quote:
Originally Posted by saratha14
my file length is almost 250 chars
Hi mate,
I guess you mean *line* length? If the file has only one long line, you could try this:
Code:
yes "`<input.dat`" | head

If it works for you, then run this:
Code:
yes "`<input.dat`" | head -n 1000000 > newfile.dat

HTH
This User Gave Thanks to junior-helper For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Alphabetical sort for multi line records contains in a single file

Hi all, I So, I've got a monster text document comprising a list of various company names and associated info just in a long list one after another. I need to sort them alphabetically by name... The text document looks like this: Company Name: the_first_company's_name_here Address:... (2 Replies)
Discussion started by: quee1763
2 Replies

2. UNIX for Dummies Questions & Answers

Getting non-duplicate records

Hi, I have a file with these records abc xyz xyz pqr uvw cde cde In my o/p file , I want all the non duplicate rows to be shown. o/p abc pqr uvw Any suggestions how to do this? Thanks for the help. rs (2 Replies)
Discussion started by: rs123
2 Replies

3. Shell Programming and Scripting

Read duplicate column, then generate a single line

Dear experts, How to generate the result listed below ? Input file: col1col2col3Aname1size1Aname2size2Aname3size1Bname4size3Bname5size5Cname6size8Cname7size6Cname8size9Cname9size11Cname10size16 What I want is: Aname1, size1name2, size2name3, size1Bname4,size3name5, size5Cname6,... (1 Reply)
Discussion started by: tojzz
1 Replies

4. Shell Programming and Scripting

Transpose multi-line records into a single row

Now that I've parsed out the data that I desire I'm left with variable length multi-line records that are field seperated by new lines (\n) and record seperated by a single empty line ("") At first I was considering doing something like this to append all of the record rows into a single row: ... (4 Replies)
Discussion started by: daveyabe
4 Replies

5. Shell Programming and Scripting

Split a single record to multiple records & add folder name to each line

Hi Gurus, I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name. I have a dir. in which... (20 Replies)
Discussion started by: ram2581
20 Replies

6. Shell Programming and Scripting

Removing duplicate records in a file based on single column

Hi, I want to remove duplicate records including the first line based on column1. For example inputfile(filer.txt): ------------- 1,3000,5000 1,4000,6000 2,4000,600 2,5000,700 3,60000,4000 4,7000,7777 5,999,8888 expected output: ---------------- 3,60000,4000 4,7000,7777... (5 Replies)
Discussion started by: G.K.K
5 Replies

7. UNIX for Dummies Questions & Answers

Need to keep duplicate records

Consider my input is 10 10 20 then, uniq -u will give 20 and uniq -dwill return 10. But i need the output as , 10 10 How we can achieve this? Thanks (4 Replies)
Discussion started by: pandeesh
4 Replies

8. Shell Programming and Scripting

Removing duplicate records in a file based on single column explanation

I was reading this thread. It looks like a simpler way to say this is to only keep uniq lines based on field or column 1. https://www.unix.com/shell-programming-scripting/165717-removing-duplicate-records-file-based-single-column.html Can someone explain this command please? How are there no... (5 Replies)
Discussion started by: cokedude
5 Replies

9. Shell Programming and Scripting

Deleting duplicate records from file 1 if records from file 2 match

I have 2 files "File 1" is delimited by ";" and "File 2" is delimited by "|". File 1 below (3 record shown): Doc1;03/01/2012;New York;6 Main Street;Mr. Smith 1;Mr. Jones Doc2;03/01/2012;Syracuse;876 Broadway;John Davis;Barbara Lull Doc3;03/01/2012;Buffalo;779 Old Windy Road;Charles... (2 Replies)
Discussion started by: vestport
2 Replies

10. Shell Programming and Scripting

Duplicate records

Gents, Please give a help file --BAD STATUS NOT RESHOOTED-- *** VP 41255/51341 in sw 2973 *** VP 41679/51521 in sw 2973 *** VP 41687/51653 in sw 2973 *** VP 41719/51629 in sw 2976 --BAD COG NOT RESHOOTED-- *** VP 41689/51497 in sw 2974 *** VP 41699/51677 in sw 2974 *** VP... (18 Replies)
Discussion started by: jiam912
18 Replies
cdb(1)							      General Commands Manual							    cdb(1)

NAME
cdb - Constant DataBase manipulation tool SYNOPSYS
cdb -q [-m] [-n num] dbname key cdb -d [-m] [dbname|-] cdb -l [-m] [dbname|-] cdb -s [dbname|-] cdb -c [-m] [-t tmpname|-] [-p perms] [-weru0] dbname [infile...] DESCRIPTION
cdb used to query, dump, list, analyze or create CDB (Constant DataBase) files. Format of cdb described in cdb(5) manpage. This manual page corresponds to version 0.78 of tinycdb package. Query cdb -q finds given key in a given dbname cdb file, and writes associated value to standard output if found (and exits with zero), or exits with non-zero if not found. dbname must be seekable file, and stdin can not be used as input. By default, cdb will print all records found. Options recognized in query mode: -nnum causes cdb to find and write a record with a given number num starting with 1 -- when there are many records with a given key. -m newline will be added after every value printed. By default, multiple values will be written without any delimiter. Dump/List cdb -d dumps contents, and cdb -l lists keys of cdbfile (or standard input if not specified) to standard output, in format controlled by presence of -m option. See subsection "Formats" below. Output from cdb -d can be used as an input for cdb -c. Create Cdb database created in two stages: temporary database is created, and after it is complete, it gets atomically renamed to permanent place. This avoids requirements for locking between readers and writers (or creaters). cdb -c will attempt to create cdb in file tmpname (or dbname with ".tmp" appended if no -t option given) and then rename it to dbname. It will read supplied infiles (or standard input if none specified). Options recognized in create mode: -t tmpname use given tmpname as temporary file. Defaults to dbname.tmp (i.e. with output file with .tmp added). Note tmpname must be in the same filesystem as output file, as cdb uses rename(2) to finalize the database creation procedure. If tmpname is a single dash (-), no temp file will be created, database will be built in-place. This mode is useful when the final renaming is done by the caller. -p perms permissions for the newly created file (usually an octal number, like 0644). By default the permissions are 0666 (with current process umask applied). If this option is specified, current umask value has no effect. -w warn about duplicate keys. -e abort on duplicate keys (implies -w). -r replace existing key with new one in case of duplicate. This may require database file rewrite to remove old records, and can be slow. -0 zero-fill existing records when duplicate records are added. This is faster than -r, but leaves extra zeros in the database file in case of duplicates. -u do not add duplicate records. -m interpret input as a sequence of lines, one record per line, with value separated from a key by space or tab characters, instead of native cdb format (see "Input/Output Format" below). Note that using any option that requires duplicate checking will slow creation process significantly, especially for large databases. Statistics cdb -s will analyze dbfile and print summary to standard output. Statistics include: total number of rows in a file, minimum, average and maximum key and value lengths, hash tables (max 256) and entries used, number of hash collisions (that is, more than one key point to the same hash table entry), minimum, average and maximum hash table size (of non-empty tables), and number of keys that sits at 10 different distances from it's calculated hash table index -- keys in distance 0 requires only one hash table lookup, 1 -- two and so on; more keys at greater distance means slower database search. Input/Output Format By default, cdb expects (for create operation) or writes (for dump/list) native cdb format data. Cdb native format is a sequence of records in a form: +klen,vlen:key->val where "+", ",", ":", "-", ">" and " " (newline) are literal characters, klen and vlen are length of key and value as decimal numbers, and key and val are key and value themselves. Series of records terminated by an empty line. This is the only format where key and value may contain any character including newline, zero () and so on. When -l option requested (list keys mode), cdb will produce slightly modified output in a form: +klen:key (note vlen and val are omitted, together with surrounding delimiters). If -m option is given, cdb will expect or produce one line for every record (newline is a record delimiter), and every line should contain optional whitespace, key, whitespace and value up to end of line. Lines started with hash character (#) and empty lines are ignored. This is the same format as mkmap(1) utility expects. OPTIONS SUMMARY
Here is a short summary of all options accepted by cdb utility: -0 zero-fill duplicate records in create (-c) mode. -c create mode. -d dump mode. -e abort (error) on duplicate key in create (-c) mode. -h print short help and exit. -l list mode. -m input or output is in "map" format, not in native cdb format. In query mode, add a newline after every value written. -nnum find and print numth record in query (-q) mode. -q query mode. -r replace duplicate keys in create (-c) mode. -s statistics mode. -t tempfile specify temporary file when creating (-c) cdb file (use single dash (-) as tempfile to stop using temp file). -u do not insert duplicate keys (unique) in create (-c) mode. -w warn about duplicate keys in create (-c) mode. AUTHOR
The tinycdb package written by Michael Tokarev <mjt@corpit.ru>, based on ideas and shares file format with original cdb library by Dan Bernstein. SEE ALSO
cdb(5), cdb(3). LICENCE
Public domain. Jan 2009 cdb(1)
All times are GMT -4. The time now is 10:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy