If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how can I split long rows in script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-05, 14:34
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
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.
Reply With Quote
  #2 (permalink)  
Old 02-04-05, 14:49
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
teletv |\
grep 88888 |\
grep 123456 |\
grep 34567 |\
grep 67890
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 02-05-05, 13:25
fla5do fla5do is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 02-05-05, 13:40
vgersh99 vgersh99 is offline
Registered User
 
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 <<!
_______________________________________\
_______________________________________\
_______________________________________
!
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+

Last edited by vgersh99; 02-05-05 at 13:52.
Reply With Quote
  #5 (permalink)  
Old 02-05-05, 14:16
fla5do fla5do is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 02-05-05, 14:27
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
"split rows" as in what?
give an example, pls!
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #7 (permalink)  
Old 02-05-05, 17:41
fla5do fla5do is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On