|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I got two problems: 1) I once saw some nifty tricks on how to use the output from one command as input for a for/while loop (looping over each line outputted). But I can't just find it any more. :-( 2) While trying to make it up myself I noticed something nasty: The output is from a secure shell connection to a machine which uses CR/LF as line terminator - something Z-Shell did not like all that much. Any ideas on what to to with unneeded CR's? Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 17 Jul., 11:38, Martin Krischik <krisc...@users.sourceforge.net>
wrote: > Hello, > > I got two problems: > > 1) I once saw some nifty tricks on how to use the output from one > command as input for a for/while loop (looping over each line > outputted). But I can't just find it any more. :-( your_command | while read -r field1 field2 rest ; do : anything ; done The number of variables to read is just an example, you may just want a single variable. > 2) While trying to make it up myself I noticed something nasty: The > output is from a secure shell connection to a machine which uses CR/LF > as line terminator - something Z-Shell did not like all that much. Any > ideas on what to to with unneeded CR's? Remove them from your data stream if you don't want them your_command | tr -d '\015' tr -d '\015' <your_data_file Janis > Martin > -- > mailto://krisc...@users.sourceforge.net > Ada programming at:http://ada.krischik.com |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 3:02 am, Janis <janis_papanag...@hotmail.com> wrote:
> On 17 Jul., 11:38, Martin Krischik <krisc...@users.sourceforge.net> > wrote: > > > Hello, > > > I got two problems: > > > 1) I once saw some nifty tricks on how to use the output from one > > command as input for a for/while loop (looping over each line > > outputted). But I can't just find it any more. :-( > > your_command | while read -r field1 field2 rest ; do : anything ; done > > The number of variables to read is just an example, you may just > want a single variable. > > > 2) While trying to make it up myself I noticed something nasty: The > > output is from a secure shell connection to a machine which uses CR/LF > > as line terminator - something Z-Shell did not like all that much. Any > > ideas on what to to with unneeded CR's? > > Remove them from your data stream if you don't want them > > your_command | tr -d '\015' > > tr -d '\015' <your_data_file > > Janis > > > Martin > > -- > > mailto://krisc...@users.sourceforge.net > > Ada programming at:http://ada.krischik.com One trick I have used in the past, not sure if it can work for you in this example, But I have used tee -a mylog.log ( append ) in the loop to get each loop to write to the same file, eg: for x in * do echo "File $x" |tee -a list.log done DANGER, this can make a big file if you run the same command using the same file name for tee, option, use "$$.log" to make new file, just a thought. 2 cents JB |
|
![]() |
| Outils de la discussion | |
|
|