Skip to main content

Thread: Shell Script Parsing Pipe Feed


i'm doing bit of shell scripting , have pipe feed so...

code:
value1|value2|value3
how parse out , each value it's own variable?

could clarify? values feed command line parameters? if yes, can read them in follows (assuming have no options command/script name):

code:
#!/bin/bash value1=$1 value2=$2 value3=$3
this not want pipe value1 value 2 etc, far, i'm not quite sure try do. if instead have 3 commands, , want pipe result of command 1 2 (etc), better off make them functions (if it's script), or use command line directly, in:

code:
#!/bin/bash value1=0 value2=0 value3=0  function1() { ... echo $value1 #note: echo should last line }  function2() { # f, insert calculation(s) using value1 value2=f($1) echo $value2 }  (similar function3())  #this assumes not hand on value function1 value1=`function1` value2=`function2 $value1` value3=`function3 $value2`
notation , use of local/global vars improved, that's gist.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Shell Script Parsing Pipe Feed


Ubuntu

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account