Sed, awk & piping

Hey all,
I'm wanting to look for a specific line and word which I have been able to with the following command
sed -n '3p' | awk {'print $2'}
I then couldn't really figure out how to properly pipe the awk result out so I made the whole command into a variable like so:
var="$(sed -n '3p' | awk {'print $2'})"
echo $var;
This give the same output.
Now one of two things. So is there a way to properly pipe the result into another sed command with out having to set it as a variable
OR
I tried using said variable to use the sed command again separately, only this time to replace the value i found.
with sed 's/$a/some_string/g' FILE  (the file is a (dot) file if it matters)
No matter how I seem to do this I can't seem to get the variable to work with the search and replace tool of SED.
Any help would be much appreciated. Let me know if sed or ed would be better to use.

So is there a way to properly pipe the result into another sed command with out having to set it as a variable
just put another vertical bar and the next command, such as the following:
sed -n '3p' input.file | awk '{print $2}' | next_command | and_the_next | etc...
var="$(sed -n '3p' | awk '{print $2}')"
echo $var;
If all you wanted to do was print the output from 'awk', then you shouldn't need to do anything special beyond:
sed -n '3p' input.file | awk '{print $2}'
as awk sends its output to standard out, just like 'echo'.  Of course if you want to do "Other" things to 'var', then it can be useful to capture the output, but to just display it via 'echo' all you need to do is let 'awk' send it to standard output as it normally does.
You 'awk' notation is wrong.  You have { 'print $2' }, when what you should have is ' { print $2 } '.  That is to say, the { print $2 } should be inside the single quotes.
If I understand your "sed -n '3p' input.file", you are printing the 3rd line of the input, then capturing the 2nd field via 'awk'.  You could do all of this with just awk
awk 'NR==3 { print $2; exit }' input.file
Where NR is the current record (line) number, so when NR == 3, it is the 3rd line.  The 'exit' stops the awk script after you get what you were after, so awk does not read the rest of the file.
If you want to capture the 2nd field for additional use in the script, such as a substitute value, then it is good to capture the field in a variable
var=$(awk 'NR==3 {print $2}' input.file)
sed -e "s/$var/some_string/g" input.file >output.file
Important things to note.  I used double-quotes "..." so that the shell will substitute the contents of $var into the 'sed' command.
HOWEVER, I use single-quotes '...' around the 'awk' commands because I DO NOT want the shell to see the $2 and the single-quotes protect the $2 from the shell, so that 'awk' can see the $2 and do the 'awk' things with $2.
The shell will perform variable substitutions inside double-quotes "...".  The shell will NOT do variable substitution inside single-quotes '...'
If you would prefer to use var=$(sed -n '3p' input.file | awk '{print $2}') that is perfectly OK, just less efficient, but if you understand it, then it works.

Similar Messages

  • "ls", "sed", "awk", etc stopped working. Help!

    After upgrading to Lion, the following commands stopped working:
    ls
    sed
    awk
    I get this error:
    Launch of "awk" failed: the PowerPC architecture is no longer supported.
    How do I get to work again?

    It sounds like you've got some old PowerPC Fink software. All of those tools are available in MacOS X, so I don't know why you would want some older PowerPC versions of the same tools.

  • Create custom dictionary viewer

    Hello there!
    I've got a digital version of a very old but very good German-Latin dictionary (maybe German users know Digitale Bibliothek), however the GUI which I have to wrap in wine is absolutely not KISS and it doesn't fit into my workflow in a tiling wm. I just discovered that I can export the whole dictionary into different formats notably XHTML, which should make it possible to create a more user friendly interface.
    The situation is as follows:
    A file which contains all the German and latin lemmata alphabetically sorted (Latin and German mixed); sample:
    abhinc#A139
    abhold#C60768
    abholen#C60769
    Abholen#D60769
    abholzen#C60770
    abhorchen#C60771
    abhorreo#A140
    abhorresco#A142
    abhorride#A143
    A file which contains all the data; sample:
    <p><a id="p0000139" /><strong>ab-hinc</strong>, Adv. I) <em>räumlich =</em> <em><strong>von hier,</strong></em> aufer abhinc lacrimas, Lucr. 3, 953 (954): toto abhinc orbe, Apul. flor. 16. – II) <em>in der Zeit:</em> 1) <em>von der gegenwärtigen Zeit rückwärts gerechnet,</em> a) <em>absol. =</em> <em><strong>von jetzt an,</strong></em> dies abhinc quintus an sextus est, cum etc., Apul.: centesimo usque abhinc saeculo, Fronto: anno abhinc tertio, Gell. – b) <em>mit</em> Acc. = <em><strong>seit nun, vor,</strong></em> abhinc annos sedecim, Caes.: abhinc annos prope viginti, Cic.: abhinc triennium, Cic., <em>Komik. u.</em> Apul. – c) <em>mit</em> Abl. = <em><strong>vor, vor ungefähr,</strong></em> qui abhinc sexaginta annis occisus foret, Plaut.: comitiis iam abhinc diebus triginta factis, Cic. <em>Vgl. (über</em> no. a <em>u.</em> b) <em>Madvig Bemerkgg. S. 65 f. Lorenz zu</em> Plaut. most. 479. – 2)<em> selten von der gegenwärtigen Zeit vorwärts gerechnet, absol. =</em> <em><strong>von jetzt an, von hier</strong></em> <em>od.</em> <em><strong>da ab,</strong></em> Pallad. 4, 13, 9. Symm. ep. 4, 59: <em>verb.</em> inde abhinc, Pacuv. 21.</p>
    <div class="db5PageBreak"> </div>
    <p> </p>
    <p><a id="p0000140" /><strong>ab-horreo</strong>, uī, ēre, I) <em>vor etwas</em> <em><strong>zurückschaudern,</strong></em><em> etwas</em> <em><strong>verabscheuen,</strong></em> <em>gegen etwas</em> <em><strong>eine starke Abneigung haben,</strong></em> <em>von etwas</em> <em><strong>aus Abscheu oder Abneigung fernbleiben, -nichts wissen wollen,</strong></em> <em>jmdm. od. einer Sache</em> <em><strong>abhold sein,</strong></em> <em>gegen jmd. od. etwas</em><em><strong> eingenommen sein,</strong></em> <em>m.</em> ab <em>u. Abl.,</em> ab hac domo, Titin.: a pace, Caes.: ab re uxoria, Ter.: a ducenda uxore, Cic.: a Berenice, Tac.: <em>mit bl.</em> Abl. <em>(s. Nipperd. zu</em> Tac. ann. 14, 21), tanto facinore procul animo, Curt.: non abh. spectaculorum oblectamentis, Tac. – <em>nachaug. m.</em> Acc., cadaverum tabem, Suet.: pumilos, Suet.: exemplum huius modi, Dict.: <em>m.</em> Infinit., Augustin. serm. 184, 3. Porphyr. Hor. carm. 1, 1, 16. – <em>absol.,</em> sin plane abhorrebit et absurdus erit,<em> sollte er aber dazu gar keine Neigung u. Fähigkeit haben,</em> Cic. de or. 2, 85: omnes aspernabantur, omnes abhorrebant, Cic. Clu. 41: ut aut cupiant (sc. reo) aut abhorreant, Cic. de or. 2, 185: postquam abhorrere eos videt, Auct. b. Afr. 73, 5. – II) <em>übtr., gleichs. von Natur mit etwas</em> <em><strong>nicht im Einklang-, im Widerspruch stehen, unverträglich-,</strong></em> <em>ihm</em> <em><strong>zuwider sein, nicht zusagen, zuwiderlaufen,</strong></em> <em>zu etwas</em> <em><strong>nicht passen,</strong></em> <em>von etw.</em> <em><strong>abweichen,</strong></em> <em>von etw.</em> <em><strong>verschieden-, fern-,</strong></em> <em>ihm</em> <em><strong>fremd sein,</strong></em> ab oculorum auriumque approbatione, <em>den Augen und Ohren anstößig sein,</em> Cic.: oratio abhorret a persona hominis gravissimi, Cic.: abh. a fide, <em>unglaublich sein,</em> Liv.: consilium abhorret a tuo scelere, Cic.: spes ab effectu haud abhorrens, <em>Hoffnung der Ausführbarkeit,</em> Liv.: temeritas tanta, ut non procul abhorreat ab insania, Cic.: longe ab ista suspicione abhorrere debet, Cic.: a quo (vitae statu) mea longissime ratio voluntasque abhorret, Cic.: orationes abhorrent inter se, <em>widersprechen einander,</em> Liv.: <em>m. bl.</em> Abl. <em>(s. Nipperd. zu</em> Tac. ann. 14, 21), abhorrens peregrinis auribus carmen, Curt.: neque abhorret vero, Tac.: nec abhorrebat moribus uxor, Flor.: <em>u.m. bl.</em> Dat., huic tam pacatae profectioni abhorrens mos, Liv.: nec abhorret a veritate <em>m.</em> folg. Acc. <em>u.</em> Infin., Suet. Cal. 12, 3. – <em>Dah.</em> abhorrens, <em><strong>unpassend, unstatthaft,</strong></em> carmen nunc abhorrens, Liv.: vestrae istae absurdae atque abhorrentes lacrimae, Liv. – ☞ Abl. abhorrenti, Gell. 10, 12, 10.</p>
    <div class="db5PageBreak"> </div>
    <p> </p>
    <p><a id="p0000142" /><strong>ab-horrēsco</strong>, ere, <em><strong>einen Abscheu bekommen,</strong></em> Eccl.<em> u.</em> Gloss.</p>
    <div class="db5PageBreak"> </div>
    Note how the id of the anchor tags correspond to the lemmata (the uppercase letter after the # may be ignored, it indicates the language or section of the lemma in the original binary file).
    In a quick-n-dirty approach I hacked a bash script (I am a bloody beginner) making use of dmenu and lynx:
    #!/bin/bash
    # display dmenu with all the lemmata, strip the id's (lemmatas in the file "data/lemmata")
    lemma="$(cat data/lemmata | sed -e 's/#[A-Z][0-9]*$//g' | dmenu)"
    # search for the selected lemmata to get the whole string with the id
    str="$(grep "^${lemma}[ .0-9()]*#[A-Z][0-9]*$" "data/lemmata")"
    id="${str#*\#[A-Z]}"
    # finally take the definition from the xml and pipe output to lynx
    awk "/<a id=\"p0*${id}\" \/>/,/<div class=\"db5PageBreak\">/{if (!/<div class=\"db5PageBreak\">/)print}" < data/dictionary.xml | lynx -stdin
    The script fires up dmenu which displays all the lemmata with all the identifiers (#<number>) stripped, then it searches the selected lemma in the lemmata file again to find the identifier and finally then the corresponding paragraph(s) is (are) taken and piped to lynx. (Using the tee program I could bind the script to a keybinding and open/close a terminal window displaying lynx)
    However this is not robust -  there are identical Latin and German lemmata:
    ab#B43
    ab#C60601
    So the approach above must fail because I don't pipe the identifiers to dmenu. I could alter the list which gets piped to dmenu to
    ab [de]
    ab [lat]
    and could then get back to the identifier...
    But the longterm goal would be a more suitable custom console interface: I am thinking of
    a terminal window which is divided into two parts, the left showing the lemmata, the right showing the definition of the lemma currently selected (think of something like a console music player, e.g. moc)
    possibility of an on the fly dmenu-like search of the lemmata while typing
    for the viewer part: automatical wrapping of the lines, colored text for <strong> and <em> tags, stripping of the HTML, scrolling (a lemma definition/translation may be very long) and display of UTF-8
    I tend to hack this in C as I lack the knowledge of any other language (as an emacs user I also thought of using emacs and displaying the definitions in w3m but I don't know any lisp other then setting variables...).
    So my questions are:
    Is this doable? If yes, which libraries should I consider? (ncurses, libhtml....)
    Does anyone know a program which does something similar?
    So far this would be my first program which makes use of menues, so any suggestions are very welcome! Any other ideas how to access lemmata and their definitions in a simple manner?
    Last edited by ball (2013-06-19 09:44:33)

    As you may have seen from the lack of replies, this is a bit hard to advise on.  Things that occur to me:
    Rather than a library, you could use regular expressions for parsing, as you already did with awk.  They are available in C via POSIX functions, see the regex (3) manual page.
    If all input you need is a decision between a small number of duplicate words, curses seems overkill.  Why not print all of them?  If you want more interaction, using curses is probably the right thing.
    Personally I would probably use Perl for this task, which is the most productive programming language I know and is especially suited for text processing.  Seeing the rather advanced shell script you wrote (definitely more than beginner level), you may like it, as it was inspired by the shell scripts using sed, awk and the like.

  • Preserve a single space at the end of line using spool command

    Hi,
    Can you please help me to write the result of an sql query into a file with the last column of the row ending with a single space?
    For example:
    COL1DATA|COL2DATA|COL3DATA<space1>
    As mentioned in the example the col3 value in the file should end with a single space. And there should not be any delimiters at the end of the row.
    I tried with set trimspool on/off. But, it didn't work. When I say trimspool on - it is trimming all the trailing spaces.
    When I say trimspool off - it is retaining all the trailing spaces to the size of the line.
    But, I do not wish to modify the file through shell commands once it is written thru spool. I mean I do not wish to append spaces to the end of a line using shell script or any other method.
    I do not wish to use other methods like UTL_FILE also.
    Please help me how to do it using spool command?
    Thank you.
    Ramana

    My requirement is that all the trailing spaces should be truncated except the last one in the row.Why?
    As you have discovered a single column in sqlplus, is always a fixed length regardless of the size of the data, if the length of the data varies the output is padded to the maximum or line size with spaces. The trim and trimpsool commands are there to remove all the spaces from the end of a line if there are any. There are no commands to trim all the spaces except one, or even to trim all the spaces except two, or three even.
    If you want such custom processing you should post process the file in the OS using sed, awk or perl or something designed for such things.

  • Creating a "Boot into Windows" button/shortcut

    Does anyone know if there is a way i can create a "boot into windows" button for linux.  I would like to put it on my linux desktop, so when i need to boot into windows, i can shutdown arch and boot right into windows, without having to go through grub and all that stuff.  I have read something about qemu, but dont really know if that will work.  Any help would be appreciated.
    Thanks!

    _Gandalf_ wrote:
    I hope you are using ext3 ...
    IMHO if you are using ext3 your problem is solved, create 2 menu.list one called menu.list.linux and the other menu.list.windows, put the default entry to the desired one and take the delay down to 0 along with hidemenu command ( boot into selected distribution instantly.. )
    On linux create the following script
    #!/bin/sh
    cp /boot/grub/menu.list.windows /boot/grub/menu.list
    [[ -f /boot/grub/menu.list ]] || exit 1
    shutdown -r now
    Now go to windows, install Ext2 FS ( http://www.fs-driver.org/ ) mount the boot partition and create a bat script
    copy E:bootgrubmenu.list.linux E:bootgrubmenu.list
    i dont remember if u can reboot from a bat script but that will do the trick...
    P.S: yea i know, it would be better to use one script and use sed/awk to patch it, but how will he patch it on windows ? personaly i don't know how :oops: so I took the idea of 2 menu.list(s)
    I am using EXT3 and i already have the Ext2fs installed, so i think those 2 scripts should do the trick!

  • Text file - replace a pattern with part of the previous line? -SOLVED

    Hello, I'm stuck with sed/awk/grep...
    So I have a file with lines like this:
    Nice bunch of words <STUFF> <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF><IMPORTANT_DELIMITER_TYPE_1><STUFF>
    Then, I want to move the "important delimiters" to new lines (might be better not to do this in fact...)
    Nice bunch of words <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1><STUFF>
    And finally, I want to replace the important delimiters with the content of the line they came from originally, up to the first angle bracket:
    Nice bunch of words <STUFF> <STUFF>
    Nice bunch of words <STUFF>
    Nice bunch of words <STUFF>
    Even Nicer bunch of Words <STUFF>
    Even Nicer bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words<STUFF>
    How can I accomplish this using absolutely anything at all that doesn't involve too much manual effort (the file is about 30,000 lines of this stuff)
    Thanks !
    Last edited by darkbeanies (2013-09-01 19:18:29)

    "<STUFF>" is not irrelevant. In your original example
    Nice bunch of words <STUFF> <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF><IMPORTANT_DELIMITER_TYPE_1><STUFF>
    you want to break the lines along the delimiters:
    Nice bunch of words <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1><STUFF>
    and then you say that you want to replace the delimiters with the contents before the first angle bracket:
    Nice bunch of words <STUFF> <STUFF>
    Nice bunch of words <STUFF>
    Nice bunch of words <STUFF>
    Even Nicer bunch of Words <STUFF>
    Even Nicer bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words<STUFF>
    but you have clearly made a distinction between the "nice bunch of words" and "<STUFF>", otherwise the output would have been
    Nice bunch of words <STUFF> <STUFF>
    Nice bunch of words <STUFF> <STUFF> <STUFF>
    So, do you want everything up to  the first delimiter, or do you want everything up to <STUFF> in the replacement? If you only want the "nicer words" then you need some way to distinguish between them and "stuff" programmatically.
    edit
    Here's a trivial script that will split the lines along the delimiters and replace them with the contents of the line before the first delimiter:
    #!/usr/bin/env python3
    import re
    import sys
    def main(args=None):
    for line in sys.stdin:
    # Trim trailing newline.
    line = line.rstrip('\n')
    # Split by delimiters.
    parts = re.split(r'<[^>]+>', line)
    print(parts[0])
    for p in parts[1:]:
    print(parts[0] + p)
    if __name__ == '__main__':
    try:
    main()
    except (KeyboardInterrupt, BrokenPipeError):
    pass
    Usage
    path/to/script < /path/to/input file
    Last edited by Xyne (2013-09-01 18:34:55)

  • [OT] Logging each logout from shell/telnet/ssh in Solaris 10

    Hi,
    excuse me for OT, how can I logging each logout on a Solaris 10 X64 and/or SPARC.
    Regards.

    > last, at now, log on login event and not logout. last command use a binary file.
    This is not true, it also logges the logout:
    root      pts/11       HOSTNAME Sat Feb  6 00:20   still logged in
    root      pts/5        HOSTNAME Thu Dec 17 00:56 - 08:50  (07:54)
    yes, it's a binary file but you could write a script that calls "last" and parse through it (using e. g. perl or sed/awk).
    > We would liket to trace login/logout on a text file from syslogd (or similar).
    You can also use /etc/syslog.conf using
    auth.notice ifdef(`LOGHOST', /var/log/authlog, @loghost)
    and following by a
    svcadm restart system-log
    Markus

  • Reading XML Files from oracle 9i or in Oracle 10g

    Hi all,
    Can any body suggest how to write a stored procedure to read XML file content and insert into a table.
    Thanking you in Advance

    I know I am blasphemous, but ....
    We had a similar requirement: one file, each line was a "simple" xml doc corresponding to one db table record. The keyword here is "simple". We looked at the xml stuff, but decided that the easiest, best runtime performance, most extensible, easiest to maintain was:
    use (sed|awk|perl) to convert xml to a flat file of fields, and then load the file with SQL*Loader. After all, loading flat files with many records is a job for SQL*Loader.
    caveat: the xml in question was very simple and the same for all records:
    timestamp|<log><id>1</id><ns>ns1</ns><prod/><cmd>order</cmd><result>ok</result><time>1813></time></log>
    "your milage may vary"
    -tom

  • Search PDF contents for ISBN number and save to text file

    Hi,
    Hoping someone can help me create a script that can find the ISBN inside of a PDF and write that filename and number to a text file.
    I've found a way to do this using java using and document processing in Acrobat but I need to do it by pointing at a folder of files.
    Format desired would be:
    original filename.pdf, isbn#
    Any help is appreciated,
    John

    you could give the command line tool ps2ascii a try. It also works with pdf and you could  pipe it's output (pure text) to a nice perl/ruby/grep/sed/awk 1-liner to extract the isbn numbers (still have to read a book about Regular Expression ;-) )
    I did a quick & dirty version, but I think you will have to install ps2ascii first. I don't remember but I think it was installed with ghostscript (using macports)
    --30.04.2011 hubionmac.com
    --quick & dirty script to extract first ISBN-Number of a PDF file... just uses grep, maybe some nice reqexp would do a better job!
    set myselection to choose file of type {"pdf"} with multiple selections allowed
    set myoutput to ""
    repeat with pdf_file in myselection
    tell application "Finder" to set pdfname to name of (pdf_file as alias)
    set pdf_file_posix to quoted form of POSIX path of (pdf_file as alias)
    do shell script ""
    try
    --first add the path, otherwhise s2ascii will fail since it cannot find ghostscript (gs) which is also installed in /usr/local/bin (think by macports)
    set ISBN_String to do shell script "PATH=\"$PATH:/usr/local/bin\"; /usr/local/bin/ps2ascii " & pdf_file_posix & " | grep -m 1 ISBN"
    set foundLine to true
    on error
    display dialog "maybe \"" & pdfname & "\" does not contain a ISBN at all"
    set foundLine to false
    end try
    if foundLine is true then
    repeat with s in every word of ISBN_String
    try
    get s as integer
    set s to s as text
    set foundisbn to true
    exit repeat
    on error
    set s to ""
    end try
    end repeat
    end if
    set myoutput to myoutput & pdfname & tab & s & return
    end repeat
    tell application "TextEdit"
    activate
    set a to make new document
    set text of a to myoutput as text
    end tell

  • Classpath settings of java for fedora5.0

    Hello All,
    I've just switched from windows to fedora5.0(linux), and have no knowledge how and from where i've to set classpath for java. Java comes inbuild with this OS, but what version it is?????any help either the full procedure or some helpful links will be greatly appreciated......thnx in adv.

    In the past, one of the major criticisms of Linuxhas
    been that it has been difficult for Jo Public touse.
    As a consequence, the move in Linux has beentowards
    ease of use and making the interface for Jo Public
    use the same metaphors as Windows. So, from a
    cosmetic point of view, Linux distributions have
    started to look like Windows BUT beneath thesurface
    they are still Linux.
    I like FCx.But from a developer's point of view, I don't think
    FC should be the choice. Developer's are here to
    learn a lot. I learnt a lot about how things actually
    go at the OS level after using linux which windows
    never provides. If everything is abstracted by FC
    through that UI, a developer will turn sluggish and
    never care to exploit the power of linux. I don't buy this. I use Linux for development and I use bash, Perl, Python, sed, awk, emacs etc etc etc. One does not have to use all these tools but if a developer wants to he can - he is not forced to use just the Windows like features.
    >
    Slack I always felt was made for developersl and a
    lot more stable than FC. Suse is more on the UI
    side, but it's as good as slack.I like UNIX/Linux. I currently use Ubuntu as my primary Linux but have installed though WMWare CentOS, Foresight, Slackware, FC7 and FreeBSD. I also have Windows XP and Windows 2000 installed though VMWare. I develop on Ubuntu and mainly use the other Linux/UNIX version to test my software.
    My favorite Linux version is FC7 and I will probably move back to using it as my primary in the near future. I hated the install of Slackware and FreeBSD - they are so old-fashioned.

  • Column name problem

    Hi all.... I have a little strange problem.. I hope you all can help me in solving this.
    for brief intro, I have an web application on MySQL written entirely in JAVA. Now we want to migrate from MySQL to Oracle... We have used Oracle Migration Workbench for migrating Schema and data. There is no problem uptill now.
    The real problem is with the column names... to clear the problem lets have an example...
    In mysql, if you execute[b] 'Select employeeID,empName from employee'  you will always get 'employeeID' and 'empName' column names in the resultset meta data... but if you executes the same query on oracle you will get 'EMPLOYEEID' and 'EMPNAME' column names in resultset meta data... then we make some xmls using these column names and then parse them and get values using HashMap... now in hashmap 'a' is different from 'A'... We did not take care of this problem while building this application. Now the application is almost completed and we are just one step away from migrating to Oracle but this problem is hindering us.
    just keep in mind there are several jsps,java beans, java services working on DB. So we need such a solution to apply on oracle and get our desired column names back from result set meta data.
    I have tried multiple solutions for this.
    1. Synonyms.. but you can only create synonyms for table not for column names
    2. Create table with double qoutes... but then we have to change all our queries which requires a lot of files to change.
    3. Create Views.... but it has same problem as of point 2.
    Can you suggest any better way to work around this problem... which require minimum effort and we migrate to oracle with existing code... Otherwise we have to do a lot of donkey work to change the code...
    Thanks in advance
    Message was edited by:
    user587592

    migrate to oracle with existing code... Otherwise we
    have to do a lot of donkey work to change the code...Is that not why SED/AWK/GREP and PERL were invented?
    As others have said, the SQL standard as well as several implementations do not support mixed- or camel-case identifiers. IN addition, only 8 character identifers are required, all else is 'above the standard'. You are facing a typical porting issue.

  • Sql Loader Skipping fields in a csv file

    Hi,
    I have a comma delimited flat file with more fields than I need and am curious if there is a loader technique
    to skip some of the fields. E.g. Given a three field file, I want to associate the 1st and 3rd fields with table columns and ignore the 2nd field.
    Sorry if this seems simple. This is my first time with loader and nothing in the Doc. Jumps out at me.
    Obviously I can massage the file prior to loader with sed, awk, perl. I'm really just curious if I can do it in loader itself.
    Thanks
    Ken

    You can use the FILLER keyword.

  • Html automation question

    I have a bunch of images on a server, and want to create a webpage where they are all available as thumbnails and ca be downloaded. I know how to do this in HTML, but I was wondering if there's an automated way to create such an html-page. It's really tedious to go through hundreds of images manually... Thanks in advance.

    tbuitenh wrote:try igal: http://www.stanford.edu/~epop/igal/
    Thanks a lot! That seems to do the trick. It's the first one I tried that I can actually run. The installation was kinda weird though. I'm not good with the whole sed-awk thing so I couldn't write a proper PKGBUILD for it...

  • Would sorting in UNIX faster than using order by?

    Hi all, recently I was trying to optimize a query that returns a million rows. After using explain plan, I found that the 'order by' (3 columns needed) clause contributes to a significant portion of the cost.
    I wonder if the process can be speed up by doing the query straight without ordering, then use the UNIX sort command (with the help of other commands, such as sed, awk... etc.) to perform the 'order by' instead. Of course you'll need to supply a whole bunch of strange parameters to sort command to make it work as expected.
    But in terms of performance when the result set is huge, which one is faster? 'Order by' or UNIX sort?
    Many thanks.

    What are you sorting by ?
    If it is a date and the output formats it with a 'Mon' component, then I'd bet on Oracle rather than any user written logic converting JAN to 01 etc.
    As for the rest of it, it may depend on the memory allocated to the processes (so PGA setting may improve query performance). A million rows would probably require a disk sort, so the location/speed of that file would impact it too.

  • WL 7.0 jCom Compling

    Hello,
    I stubbed out my COM dll fine. But when I went to compile the .java files, it could
    not find the com.bea.jcom.Dispatch class. This class was not in weblogic.jar.
    Anybody know where it is?
    TIA,
    Jeff

    There are a whole bunch of objects besides the documented Dispatch that are missing
    from weblogic jar. I changed the locations to com.linar.jintegra and finally got
    it to compile, but could not make any invocations because I got Jintegra licensing
    error messages.
    My attempts to go in the COM-WLS direction have been equally unsuccessful. Using
    a late-bound client, binding with the jndi moniker does not seem to work. Also,
    attempting to obtain a jvm moniker results in the following error:
    U:\>java com.bea.jcom.GetJvmMoniker localhost 7001
    J-Integra 1.5.0 SB004 Copyright (C) 1999-2001 Intrinsyc Software Inc. http://www
    .intrinsyc.com/j-integra/
    java.lang.RuntimeException: No valid licensing information found.
    In order to use the J-Integra runtime a proper license file must be installed.
    If you have acquired a license, or if you are evaluating J-Integra or any
    J-Integra Integra products, then you should have received such a license file, t
    ogether
    with installation instructions by email when you downloaded the kit.
    If you are having trouble installing the license, please goto http://www.intrins
    yc.com
    or refer to your documetation in the section about Licensing
    Help!!
    "lars" <[email protected]> wrote:
    >
    To make the picture complete the typelibrary I used is based on a C# component.
    "lars" <[email protected]> wrote:
    I changed my code according to what you wrote but I still get compilererrors
    for
    "_Object" and "_ProxyObject" which can't be located.
    Is there a working example for communication from Java to Com?
    dan seeman <[email protected]> wrote:
    FYI - you'll find an equivalent issue documented in
    http://e-docs.bea.com/wls/docs70/notes/issues.html#1071850.
    dan
    dan seeman wrote:
    Hi,
    This is a known issue. The Dispatch class is located in com.linar.jintegra.Dispatch.
    For now you'll have to hand-edit your generated classes to import andreference this
    class location. If you have more than a few generated classes, a quickscript (perl,
    python, sed, awk) is probably best suited to this task.
    We apologize for the mistake. The issue will be resolved in a futurerelease.
    dan
    Jeff Blumenthal wrote:
    Hello,
    I stubbed out my COM dll fine. But when I went to compile the .java
    files, it could
    not find the com.bea.jcom.Dispatch class. This class was not in weblogic.jar.
    Anybody know where it is?
    TIA,
    Jeff

Maybe you are looking for