RE: joining word/ lines in a file
Thanks Steven, Jared for the ideas. Regards Suhen -- Suhen Pather [EMAIL PROTECTED] Hey this is a not a trick question, without buying the books listed below is there a way using the std awk, sed, tr *nix utilities. Perl is going to be the simplest since it has a regex for whitespace and you can easily change the input record specifier (undef $/ for slurp mode). -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582 -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Steven Lembark INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: joining word/ lines in a file
Suhen - Actually you've hit one of the limitations of the traditional Unix tools such as awk, sed, etc. The perform multi-line changes only with difficulty. Perl is as powerful and easy to use as each of those individually, and offers incredible strengths beyond those. As a bonus, Perl is available on just about any platform. I have used it quite a bit on MS-DOS, for example. Spend your time learning Perl. There are some excellent manuals on-line. Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] -Original Message- Sent: Wednesday, May 29, 2002 1:04 AM To: Multiple recipients of list ORACLE-L Hey this is a not a trick question, without buying the books listed below is there a way using the std awk, sed, tr *nix utilities. Suhen Flex, Bison some programming will probably do the trick. There is a nice O'Reilly book dealing with Lex Yacc wnd even nicer book dealing with the C programming language. The Good Book is: Brian Kernighan and Dennis Ritchie: The C Programming Language. You should get the King James (ANSII) edition. On 2002.05.28 23:58 Suhen Pather wrote: List, slightly off topic but Unix OS I need to join lines/ words in a file. So that it must be in a readable Oracle format. They are seperated by a newline. Here is a snippet of what the file looks like. FILE1 delete from JDAPROD.HBI_LOST_SALES where SKU_TECHNICAL_KEY = 1410 and STORE_TECH NICAL_KEY = 276 and STORE_NO = 315 and STORE_NAME = 'Glenfield SB 315 ' and SKU = '1516803' and SKU_NAME = 'WMERE ORGAN ISER Black ' and DEPT = '052' and DEPT_N AME = 'Travel Bags' and CLASS = '05211 ' and CLASS_NAME = 'Travel Bags' a nd FORMAT_EXISTS = 'Y' and STOCK_ON_HAND = 2 and STOCK_IN_WAREHOUSE = 433 and RE QUESTED_UNITS = 0 and ALLOCATED_UNITS = 0 and UNIT_SALES_CURRENT_DAY = 0 and UNI T_SALES_LAST_7_DAYS = 0 and UNIT_SALES_LAST_6_WEEKS = 2 and ON_HAND_COST = 41.23 7 and ON_HAND_RETL = 167.333 and GROUP_NO = '05 ' and GROUP_NAME = ' Travel' and EST_STOCK = 0 and INTRANSIT = 2 and DATE_RUN = TO_DATE('27MAY2002 00:00:00', 'DDMON HH24:MI:SS') and ON_ORDER = 150; I am trying using sed but cant seem to work it out. Any Ideas? Regards Suhen -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Mladen Gogala -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mladen Gogala INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: DENNIS WILLIAMS INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: joining word/ lines in a file
$ perl -e 'print join \n, ' myfile; -- Suhen Pather [EMAIL PROTECTED] List, slightly off topic but Unix OS I need to join lines/ words in a file. So that it must be in a readable Oracle format. They are seperated by a newline. Here is a snippet of what the file looks like. FILE1 delete from JDAPROD.HBI_LOST_SALES where SKU_TECHNICAL_KEY = 1410 and STORE_TECH NICAL_KEY = 276 and STORE_NO = 315 and STORE_NAME = 'Glenfield SB 315 ' and SKU = '1516803' and SKU_NAME = 'WMERE ORGAN ISER Black ' and DEPT = '052' and DEPT_N AME = 'Travel Bags' and CLASS = '05211 ' and CLASS_NAME = 'Travel Bags' a nd FORMAT_EXISTS = 'Y' and STOCK_ON_HAND = 2 and STOCK_IN_WAREHOUSE = 433 and RE QUESTED_UNITS = 0 and ALLOCATED_UNITS = 0 and UNIT_SALES_CURRENT_DAY = 0 and UNI T_SALES_LAST_7_DAYS = 0 and UNIT_SALES_LAST_6_WEEKS = 2 and ON_HAND_COST = 41.23 7 and ON_HAND_RETL = 167.333 and GROUP_NO = '05 ' and GROUP_NAME = ' Travel' and EST_STOCK = 0 and INTRANSIT = 2 and DATE_RUN = TO_DATE('27MAY2002 00:00:00', 'DDMON HH24:MI:SS') and ON_ORDER = 150; I am trying using sed but cant seem to work it out. Any Ideas? Regards Suhen -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582 -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Steven Lembark INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: joining word/ lines in a file
oops, wrong direction -- you wanted to take out the newlines. use chomp and print the resulting array with $, left at the default value: $ perl -e 'chomp (my @a = ); print @a' myfile [anotherfile ...]; i.e., read from ARGV, put it all in an array, slice off the input record separators; print the array. -- Suhen Pather [EMAIL PROTECTED] List, slightly off topic but Unix OS I need to join lines/ words in a file. So that it must be in a readable Oracle format. They are seperated by a newline. Here is a snippet of what the file looks like. FILE1 delete from JDAPROD.HBI_LOST_SALES where SKU_TECHNICAL_KEY = 1410 and STORE_TECH NICAL_KEY = 276 and STORE_NO = 315 and STORE_NAME = 'Glenfield SB 315 ' and SKU = '1516803' and SKU_NAME = 'WMERE ORGAN ISER Black ' and DEPT = '052' and DEPT_N AME = 'Travel Bags' and CLASS = '05211 ' and CLASS_NAME = 'Travel Bags' a nd FORMAT_EXISTS = 'Y' and STOCK_ON_HAND = 2 and STOCK_IN_WAREHOUSE = 433 and RE QUESTED_UNITS = 0 and ALLOCATED_UNITS = 0 and UNIT_SALES_CURRENT_DAY = 0 and UNI T_SALES_LAST_7_DAYS = 0 and UNIT_SALES_LAST_6_WEEKS = 2 and ON_HAND_COST = 41.23 7 and ON_HAND_RETL = 167.333 and GROUP_NO = '05 ' and GROUP_NAME = ' Travel' and EST_STOCK = 0 and INTRANSIT = 2 and DATE_RUN = TO_DATE('27MAY2002 00:00:00', 'DDMON HH24:MI:SS') and ON_ORDER = 150; I am trying using sed but cant seem to work it out. Any Ideas? Regards Suhen -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582 -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Steven Lembark INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: joining word/ lines in a file
Here's a perl one liner: perl -ne 'chomp; print; print qq{\n} if /\;$/' file1.txt newfile.txt If isn't perfect. An 'and' at the end of the line will be joined with the beginning of the next line, which is not right. I use the following two regular expressions to create executable SQL from v$sqltext. You may find them useful if you explore your Perl options. $sql =~ s/ (--\s*(([\w]+)\s+))? (?= and\s+[\w+\.+]+\s*(\=|between|\\|\!\=) |or\s+[\w+\.+]+\s*(\=|between|\\|\!\=) |where\s+[\w+\.+]+\s*(\=|between|\\|\!\=) |select |union |minus |intersection |from |where |order\s+by |group\s+by ) /\n$5/gomix; $sql =~ s/(\s+ --\s*where |--\s*from |--\s*group\s+by |--\s*order\s+by |--\s*select |--\s*union |--\s*minus |--\s*intersection #|select #|union #|minus #|intersection #|from #|where #|order\s+by #|group\s+by\s+ )/\n$1/gomix; Jared On Tuesday 28 May 2002 20:58, Suhen Pather wrote: List, slightly off topic but Unix OS I need to join lines/ words in a file. So that it must be in a readable Oracle format. They are seperated by a newline. Here is a snippet of what the file looks like. FILE1 delete from JDAPROD.HBI_LOST_SALES where SKU_TECHNICAL_KEY = 1410 and STORE_TECH NICAL_KEY = 276 and STORE_NO = 315 and STORE_NAME = 'Glenfield SB 315 ' and SKU = '1516803' and SKU_NAME = 'WMERE ORGAN ISER Black ' and DEPT = '052' and DEPT_N AME = 'Travel Bags' and CLASS = '05211 ' and CLASS_NAME = 'Travel Bags' a nd FORMAT_EXISTS = 'Y' and STOCK_ON_HAND = 2 and STOCK_IN_WAREHOUSE = 433 and RE QUESTED_UNITS = 0 and ALLOCATED_UNITS = 0 and UNIT_SALES_CURRENT_DAY = 0 and UNI T_SALES_LAST_7_DAYS = 0 and UNIT_SALES_LAST_6_WEEKS = 2 and ON_HAND_COST = 41.23 7 and ON_HAND_RETL = 167.333 and GROUP_NO = '05 ' and GROUP_NAME = ' Travel' and EST_STOCK = 0 and INTRANSIT = 2 and DATE_RUN = TO_DATE('27MAY2002 00:00:00', 'DDMON HH24:MI:SS') and ON_ORDER = 150; I am trying using sed but cant seem to work it out. Any Ideas? Regards Suhen -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jared Still INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: joining word/ lines in a file
Flex, Bison some programming will probably do the trick. There is a nice O'Reilly book dealing with Lex Yacc wnd even nicer book dealing with the C programming language. The Good Book is: Brian Kernighan and Dennis Ritchie: The C Programming Language. You should get the King James (ANSII) edition. On 2002.05.28 23:58 Suhen Pather wrote: List, slightly off topic but Unix OS I need to join lines/ words in a file. So that it must be in a readable Oracle format. They are seperated by a newline. Here is a snippet of what the file looks like. FILE1 delete from JDAPROD.HBI_LOST_SALES where SKU_TECHNICAL_KEY = 1410 and STORE_TECH NICAL_KEY = 276 and STORE_NO = 315 and STORE_NAME = 'Glenfield SB 315 ' and SKU = '1516803' and SKU_NAME = 'WMERE ORGAN ISER Black ' and DEPT = '052' and DEPT_N AME = 'Travel Bags' and CLASS = '05211 ' and CLASS_NAME = 'Travel Bags' a nd FORMAT_EXISTS = 'Y' and STOCK_ON_HAND = 2 and STOCK_IN_WAREHOUSE = 433 and RE QUESTED_UNITS = 0 and ALLOCATED_UNITS = 0 and UNIT_SALES_CURRENT_DAY = 0 and UNI T_SALES_LAST_7_DAYS = 0 and UNIT_SALES_LAST_6_WEEKS = 2 and ON_HAND_COST = 41.23 7 and ON_HAND_RETL = 167.333 and GROUP_NO = '05 ' and GROUP_NAME = ' Travel' and EST_STOCK = 0 and INTRANSIT = 2 and DATE_RUN = TO_DATE('27MAY2002 00:00:00', 'DDMON HH24:MI:SS') and ON_ORDER = 150; I am trying using sed but cant seem to work it out. Any Ideas? Regards Suhen -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Mladen Gogala -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mladen Gogala INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: joining word/ lines in a file
-- Jared Still [EMAIL PROTECTED] If isn't perfect. An 'and' at the end of the line will be joined with the beginning of the next line, which is not right. Don't strip the newlines, replace them with white space: perl -e 'undef $/; ($a=ARGV) =~ s/\n+/ /g; print $a' \ [file [file...]] [file] i.e., slurp the input whole, replace any sequence of one-or- more newlines with a single space and spit out the result. If the input doesn't have multiple spaces in the fields you might get better result to strip newlines followed by whitespace: ... ~= s/\n\s+/ /g will take any single newline and all the whitespace that follows it and replace the result with a space. If none of the data fields being hacked have spaces in them a further: $a =~ s/ +/ /g will replace one or more literal spaces with a single space to clean things up a bit: ... -e 'undef $/;($a=ARGV) =~ s/\n+/ /g;s/ +/ /g;print $a' ... will convert nearly anything you can give it into a nice, clean, single line. If you want to get things neater than this see the examples in Parse::RecDescent. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582 -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Steven Lembark INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: joining word/ lines in a file
Hey this is a not a trick question, without buying the books listed below is there a way using the std awk, sed, tr *nix utilities. Suhen Flex, Bison some programming will probably do the trick. There is a nice O'Reilly book dealing with Lex Yacc wnd even nicer book dealing with the C programming language. The Good Book is: Brian Kernighan and Dennis Ritchie: The C Programming Language. You should get the King James (ANSII) edition. On 2002.05.28 23:58 Suhen Pather wrote: List, slightly off topic but Unix OS I need to join lines/ words in a file. So that it must be in a readable Oracle format. They are seperated by a newline. Here is a snippet of what the file looks like. FILE1 delete from JDAPROD.HBI_LOST_SALES where SKU_TECHNICAL_KEY = 1410 and STORE_TECH NICAL_KEY = 276 and STORE_NO = 315 and STORE_NAME = 'Glenfield SB 315 ' and SKU = '1516803' and SKU_NAME = 'WMERE ORGAN ISER Black ' and DEPT = '052' and DEPT_N AME = 'Travel Bags' and CLASS = '05211 ' and CLASS_NAME = 'Travel Bags' a nd FORMAT_EXISTS = 'Y' and STOCK_ON_HAND = 2 and STOCK_IN_WAREHOUSE = 433 and RE QUESTED_UNITS = 0 and ALLOCATED_UNITS = 0 and UNIT_SALES_CURRENT_DAY = 0 and UNI T_SALES_LAST_7_DAYS = 0 and UNIT_SALES_LAST_6_WEEKS = 2 and ON_HAND_COST = 41.23 7 and ON_HAND_RETL = 167.333 and GROUP_NO = '05 ' and GROUP_NAME = ' Travel' and EST_STOCK = 0 and INTRANSIT = 2 and DATE_RUN = TO_DATE('27MAY2002 00:00:00', 'DDMON HH24:MI:SS') and ON_ORDER = 150; I am trying using sed but cant seem to work it out. Any Ideas? Regards Suhen -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Mladen Gogala -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mladen Gogala INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: joining word/ lines in a file
-- Suhen Pather [EMAIL PROTECTED] Hey this is a not a trick question, without buying the books listed below is there a way using the std awk, sed, tr *nix utilities. Perl is going to be the simplest since it has a regex for whitespace and you can easily change the input record specifier (undef $/ for slurp mode). -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582 -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Steven Lembark INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).