Sponsored Content
Top Forums Shell Programming and Scripting Merging several line in one based on an occurrence Post 302594036 by xanthos on Monday 30th of January 2012 09:19:50 AM
Old 01-30-2012
Merging several line in one based on an occurrence

Hi,

I try to gather several line in one based on the first column.

For exemple :

Code:
toto;1;2;3
toto;4;5;6
toto;7;8;9
etc...   (Number of lines not predefined)
ruru;a;b;c
ruru;d;e;f
ruru;g;h;i
...

I'm trying to get :

Code:
toto;1;2;3;4;5;6;7;8;9...
ruru;a;b;c;d;e;f;g;h;i...

Thank you.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merging two files based on some key

I have to merge two files: The files are having the same format like A0this is first line TOlast line silmilarly other lines. I have to search for A0 line in the second file also and then put the data in the third file under A0 heading ,then for A1 and so on. A0 portion will be treminated... (1 Reply)
Discussion started by: Vandana Yadav
1 Replies

2. Shell Programming and Scripting

Merging of all files based on a condition

Hi Friends, I am new to UNIX. I need to merge all the files(to FINAL.txt) in single directory based one condition. Out of all the files one of file will have specific value like :GF01: at any where in the file. so the file which is having :GF01: should be appended at the last. EX:... (5 Replies)
Discussion started by: arund_01
5 Replies

3. Shell Programming and Scripting

Count no of occurrence of the strings based on column value

Can anyone help me to count number of occurrence of the strings based on column value. Say i have 300 files with 1000 record length from which i need to count the number of occurrence string which is existing from 213 to 219. Some may be unique and some may be repeated. (8 Replies)
Discussion started by: zooby
8 Replies

4. Shell Programming and Scripting

merging two files based on first column

I had two files file1 and file2. I want a o/p file(file3) like below using first column as ref. Pls give suggestion ass join is not working as the number of lines in each file is nealry 5 C? file1 --------------------- 404000324810001 Y 404000324810004 N 404000324810008 Y 404000324810009 N... (1 Reply)
Discussion started by: p_sai_ias
1 Replies

5. Shell Programming and Scripting

Merging two files with merging line by line

Hi, I have two files and i want to merge it like, file1.txt --------- abc cde efg file2.txt ------- 111 222 333 Output file should be, -------------- abc 111 (2 Replies)
Discussion started by: rbalaj16
2 Replies

6. UNIX for Dummies Questions & Answers

Merging lines based on one column

Hi, I have a file which I'd like to merge lines based on duplicates in one column while keeping the info for other columns. Let me simplify it by an example: File ESR1 ANASTROZOLE NA FDA_approved ESR1 CISPLATIN NA FDA_approved ESR1 DANAZOL agonist NA ESR1 EXEMESTANE NA FDA_approved... (3 Replies)
Discussion started by: JJ001
3 Replies

7. Shell Programming and Scripting

Merging 2 lines based on a string

Dear Unix gurus I need help with a command or script to merge 2 lines where ever we find the string. I have attached scanned document. First line has string value: VSIN, immediate line has value: SETTLEMENT Where it finds the 2 string values in the whole file, one below the other,... (8 Replies)
Discussion started by: Karunyam
8 Replies

8. UNIX for Dummies Questions & Answers

Count occurrence of string (based on type) in a column using awk

Hello, I have a table that looks like what is shown below: AA BB CC XY PQ RS AA BB CC XY RS I would like the total counts depending on the set they belong to: if search pattern is in {AA, BB, CC} --> count them as Type1 | wc -l (3 Replies)
Discussion started by: Gussifinknottle
3 Replies

9. UNIX for Beginners Questions & Answers

Merging multiple lines into single line based on one column

I Want to merge multiple lines based on the 1st field and keep into single record. SRC File: AAA_POC_DB.TAB1 AAA_POC_DB.TAB2 AAA_POC_DB.TAB3 AAA_POC_DB.TAB4 BBB_POC_DB.TAB1 BBB_POC_DB.TAB2 CCC_POC_DB.TAB6 OUTPUT ----------------- 'AAA_POC_DB','TAB1','TAB2','TAB3','TAB4'... (10 Replies)
Discussion started by: raju2016
10 Replies

10. UNIX for Beginners Questions & Answers

Merging rows based on same ID in First column.

Hellow, I have a tab-delimited file with 3 columns : BINPACKER.13259.1.p2 SSF48239 BINPACKER.13259.1.p2 PF13243 BINPACKER.13259.1.p2 G3DSA:1.50.10.20 BINPACKER.13259.2.p2 SSF48239 BINPACKER.13259.2.p2 PF13243 BINPACKER.13259.2.p2 G3DSA:1.50.10.20... (7 Replies)
Discussion started by: anjaliANJALI
7 Replies
rheostream(2rheolef)						    rheolef-6.1 					      rheostream(2rheolef)

NAME
irheostream, orheostream - large data streams ABSTRACT
This class provides a stream interface for large data management. File decompresion is assumed using gzip and a recursive seach in a directory list is provided for input. orheostream foo("NAME", "suffix"); is like ofstream foo("NAME.suffix"). However, if NAME does not end with `.suffix', then `.suffix' is added, and compression is done with gzip, adding an additional `.gz' suffix. Conversely, irheostream foo("NAME","suffix"); is like ifstream foo("NAME.suffix"). However, we look at a search path environment variable RHEOPATH in order to find NAME while suffix is assumed. Moreover, gzip compressed files, ending with the `.gz' suffix is assumed, and decompression is done. Finally, a set of useful functions are provided. DESCRIPTION
The following code: irheostream is("results", "data"); will recursively look for a `results[.data[.gz]]' file in the directory mentionned by the RHEOPATH environment variable. For instance, if you insert in our ".cshrc" something like: setenv RHEOPATH ".:/home/dupont:/usr/local/math/demo" the process will study the current directory `.', then, if neither `square.data.gz' nor `square.data' exits, it scan all subdirectory of the current directory. Then, if file is not founded, it start recusively in `/home/dupond' and then in `/usr/local/math/demo'. File decompression is performed by using the gzip command, and data are pipe-lined directly in memory. If the file start with `.' as `./square' or with a `/' as `/home/oscar/square', no search occurs and RHEOPATH environment variable is not used. Also, if the environment variable RHEOPATH is not set, the default value is the current directory `.'. For output stream: orheostream os("newresults", "data"); file compression is assumed, and "newresults.data.gz" will be created. File loading and storing are mentionned by a message, either: ! load "./results.data.gz" or: ! file "./newresults.data.gz" created. on the clog stream. By adding the following: clog << noverbose; you turn off these messages (see iorheo(4)). IMPLEMENTATION
class irheostream : public io::filtering_stream<io::input> { public: irheostream() : io::filtering_stream<io::input>() {} irheostream(const std::string& name, const std::string& suffix = std::string()); virtual ~irheostream(); void open (const std::string& name, const std::string& suffix = std::string()); void close(); protected: std::ifstream _ifs; }; class orheostream : public io::filtering_stream<io::output> { public: orheostream() : io::filtering_stream<io::output>() {} orheostream(const std::string& name, const std::string& suffix = std::string()); virtual ~orheostream(); void open (const std::string& name, const std::string& suffix = std::string()); void close(); protected: std::ofstream _ofs; }; std::string itos (std::string::size_type i); std::string ftos (const Float& x); // catch first occurence of string in file bool scatch (std::istream& in, const std::string& ch); // has_suffix("toto.suffix", "suffix") -> true bool has_suffix (const std::string& name, const std::string& suffix); // "toto.suffix" --> "toto" std::string delete_suffix (const std::string& name, const std::string& suffix); // "/usr/local/dir/toto.suffix" --> "toto.suffix" std::string get_basename (const std::string& name); // "/usr/local/dir/toto.suffix" --> "/usr/local/dir" std::string get_dirname (const std::string& name); // "toto" --> "/usr/local/math/data/toto.suffix" std::string get_full_name_from_rheo_path (const std::string& rootname, const std::string& suffix); // "." + "../geodir" --> ".:../geodir" void append_dir_to_rheo_path (const std::string& dir); // "../geodir" + "." --> "../geodir:." void prepend_dir_to_rheo_path (const std::string& dir); bool file_exists (const std::string& filename); // string to float bool is_float (const std::string&); Float to_float (const std::string&); // in TMPDIR environment variable or "/tmp" by default std::string get_tmpdir(); SEE ALSO
iorheo(4) rheolef-6.1 rheolef-6.1 rheostream(2rheolef)
All times are GMT -4. The time now is 11:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy