Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138

    Unanswered: how can I split long rows in script

    Hi Users,

    how can I split a long row in shell-script ( more than 80 characters ) in
    one or more rows for better reading.

    Exampe :

    unload medcome2 teletv | grep 88888 | grep 123456 | grep 34567 | grep 67890 > /usr2/medcom2/tmp/teletv

    that is what I want !

    unload medcome2 teletv
    | grep 88888
    | grep 123456
    | grep 34567
    | grep 67890
    > /usr2/medcom2/tmp/teletv

    Is that possible ?
    Greetings from germany
    Peter F.

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    teletv |\
    grep 88888 |\
    grep 123456 |\
    grep 34567 |\
    grep 67890
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  3. #3
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138
    Hi vgersh99,

    thanks, it works fine. But in this case it does not work completely.

    I want to give out 80 underlines in one line to the screen with "echo comand" like this :

    echo "____________________"\
    "____________________"\
    "____________________"\
    "____________________"\

    the result is following :
    ___________________ ____________________ and so on

    Between the four lines ist a blank
    Greetings from germany
    Peter F.

  4. #4
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    how about a very simple awk - you can make a '80' a parameter to the script:

    Code:
    nawk 'BEGIN{$80=OFS="_";print}'
    OR with cat:
    Code:
    cat <<!
    _______________________________________\
    _______________________________________\
    _______________________________________
    !
    Last edited by vgersh99; 02-05-05 at 14:52.
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  5. #5
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138
    Hi vgersh99,

    thank you for your comments.

    I have to teach the first basic commands in shell scripting.

    awk and nawk is the next practice, I can not use it in the first lesson.

    Thanks a lot

    Is there a way to split rows in awk too ??
    Greetings from germany
    Peter F.

  6. #6
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    "split rows" as in what?
    give an example, pls!
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  7. #7
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138
    I mean this :
    The following row is displays in 3 lines on the screen.

    I want to split it in x line for better reading.

    Pat=`echo $i | awk ' BEGIN {
    printf ("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s%s%s%s%s%s\n",F1,F4,TelNr,R,PatNr,R,WR,T elJN,R,TVJN,R,Abbu,R,R,ChipJN,R,ChipNr,R,Name,R,St r,R,PLZ,R,Ort,R,Bank,R,BLZ,R,KTNR,R,F7,F10) > "/usr2/medcom2/bin/Chip.anm"
    }'`

    Split like this :

    TAB TAB Pat=`echo $i | awk ' BEGIN {
    TAB TAB printf ("%s%s%s%s%s%s%s%s%s%s%s%s%s
    TAB TAB %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%
    TAB TAB s%s%s%s%s%s\n",F1,F4,TelNr,R,PatNr,R,WR,TelJN,R,
    TAB TAB TVJNTAB TAB ,R,Abbu,R,R,ChipJN,R,ChipNr,R,Name,R,Str,R,PLZ,
    TAB TAB R,Ort,R,Bank,R,BLZ,R,KTNR,R,F7,F10)
    TAB TAB > "/usr2/medcom2/bin/Chip.anm"
    TAB TAB }'`

    The problem in this editor (dbforum) is , the Tabulator (TAB) is not shown !

    I hope I can explain my problem.

    Thanks for help.
    Greetings from germany
    Peter F.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •