Sponsored Content
Top Forums Shell Programming and Scripting Extract patterns and copy them in different files Post 302550450 by shoaibjameel123 on Thursday 25th of August 2011 11:11:31 PM
Old 08-26-2011
Even better Smilie

---------- Post updated at 11:11 AM ---------- Previous update was at 10:17 AM ----------

I am now trying to find those lines which have ZERO dot and store those lines in A.dat and then the lines which have 1 dot store them in B.dat and two dots store them in C.dat and so on until I reach the final number of dots at maximum they are 11 and less.

This is an illustration:

main_file.txt which looks like this:

Code:
Name1;A01
Name2;A01.047
Name3;A01.047.025
Newname1;B01
NewName2;B01.056.32
NewName3;B04.09.43
NewNewName1;C01.03
NewNewName2;C01.034.44

So, this is what I expect:
A.dat

Code:
Name1;A01
Newname1;B01

B.dat

Code:
Name2;A01.047

C.dat

Code:
Name3;A01.047.025
NewName2;B01.056.32
NewName3;B04.09.43
NewNewName2;C01.034.44

This is what I tried but to no success:

Code:
perl -lne '$c=1 while /./g; END { print $c."dat"; }'

Even the part that gives file names is not perfect.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To extract the string between two patterns

Sample input: Loading File System Networking in nature Closing the System now i need to extract the patterns between the words File and Closing: i.e. sample output: System Networking in Nature Thanks in advance !!!!!!!!!!!!!!!!! (6 Replies)
Discussion started by: aajan
6 Replies

2. Shell Programming and Scripting

Extract certain patterns from file.

Hi All, I tried extracting this pattern using grep but it did not work. What I have is a file which has contents like this: file:///channel/add-adhd.html file:///channel/allergies.html file:///channel/arthritis.html http://mail.yahoo.com/ http://messenger.yahoo.com/... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

3. UNIX for Dummies Questions & Answers

Search and extract matching patterns

%%%%% (9 Replies)
Discussion started by: lucasvs
9 Replies

4. Shell Programming and Scripting

Extract line between two patterns

Hi All, I need a script to extract a lines between two patterns.I have done this using grep,cut,tail and head.But its very slow, because my input file contain more than a lakh. COMMAND:XXXXXXXXXXXXXXXXXXXX yyyyy zzzzzz REQUESTSTRING:aaaaaaaaaaaaaaa;11111 222222 333333... (4 Replies)
Discussion started by: rajamohan
4 Replies

5. Shell Programming and Scripting

Need to extract text repetitively between two patterns

Hi All, I want to extract the text between some pattern which occurs repeatedly in a file. For example my input is like, /home/..... ..........java:25: cannot find symbol ............ /home/...... /home/....... I want to display... (2 Replies)
Discussion started by: Vignesh58
2 Replies

6. Shell Programming and Scripting

Extract all the lines in between of 2 patterns and merge them

Hi, I have a file with many lines and need to extract lines between 2 patterns (AAA and BBB) and merge all the in-between lines into single line separated by space. $ cat file1 blah blah blah blah AAA 1 2 3 blah BBB blah blah blah blah blah blah blah blah blah AAA 5 6 blah blah... (4 Replies)
Discussion started by: prvnrk
4 Replies

7. Shell Programming and Scripting

Extract all the sentences that matched two patterns

Hi I have two lists of patterns named A and B consisting of around 200 entries in each and I want to extract all the sentences from a big text file which match atleast one pattern from both A and B. For example, pattern list A consists of : ama ani ahum mari ... ... and pattern... (1 Reply)
Discussion started by: my_Perl
1 Replies

8. Shell Programming and Scripting

Extract lines between patterns

I have a list in the format below, how do I read through the list and extract the lines between the ##START## and ##END##, so i can check for specific values between each ##START## & ##END## pattern ##START## RANDOMTEXT DFGSD SDFSDF ##END## ##START## morestuff sdfggfg sdfsdf... (10 Replies)
Discussion started by: squrcles
10 Replies

9. Shell Programming and Scripting

Bash - Find files excluding file patterns and subfolder patterns

Hello. For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Discussion started by: jcdole
2 Replies

10. UNIX for Beginners Questions & Answers

Match patterns between two files and extract certain range of strings

Hi, I need help to match patterns from between two different files and extract region of strings. inputfile1.fa >l-WR24-1:1 GCCGGCGTCGCGGTTGCTCGCGCTCTGGGCGCTGGCGGCTGTGGCTCTACCCGGCTCCGG GGCGGAGGGCGACGGCGGGTGGTGAGCGGCCCGGGAGGGGCCGGGCGGTGGGGTCACGTG... (4 Replies)
Discussion started by: bunny_merah19
4 Replies
MLLP_SEND(1)							    python-hl7							      MLLP_SEND(1)

NAME
mllp_send - MLLP network client python-hl7 features a simple network client, mllp_send, which reads HL7 messages from a file or sys.stdin and posts them to an MLLP server. mllp_send is a command-line wrapper around hl7.client.MLLPClient. mllp_send is a useful tool for testing HL7 interfaces or resending logged messages: $ mllp_send --file sample.hl7 --port 6661 mirth.example.com MSH|^~&|LIS|Example|Hospital|Mirth|20111207105244||ACK^A01|A234244|P|2.3.1| MSA|AA|234242|Message Received Successfully| USAGE
Usage: mllp_send [options] <server> Options: -h, --help show this help message and exit -p PORT, --port=PORT port to connect to -f FILE, --file=FILE read from FILE instead of stdin -q, --quiet do not print status messages to stdout --loose allow file to be a HL7-like object ( instead of ). Can ONLY send 1 message. Requires --file option (no stdin) INPUT FORMAT
By default, mllp_send expects the FILE or stdin input to be a properly formatted HL7 message (carriage returns separating segments) wrapped in a MLLP stream (<SB>message1<EB><CR><SB>message2<EB><CR>...). However, it is common, especially if the file has been manually edited in certain text editors, that the ASCII control characters will be lost and the carriage returns will be replaced with the platform's default line endings. In this case, mllp_send provides the --loose option, which attempts to take something that "looks like HL7" and convert it into a proper HL7 message. Currently the --loose option can only handle 1 HL7 message per file (it causes mllp_send to assume the whole file is one HL7 message). ADDITIONAL RESOURCES
o http://python-hl7.readthedocs.org AUTHOR
John Paulett COPYRIGHT
2011, John Paulett 0.2.2 December 17, 2011 MLLP_SEND(1)
All times are GMT -4. The time now is 06:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy