help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: While loop and stdin


From: Greg Wooledge
Subject: Re: While loop and stdin
Date: Thu, 15 Feb 2024 08:41:21 -0500

On Thu, Feb 15, 2024 at 07:56:12AM -0500, Zachary Santer wrote:
> Alright, so the problem's been solved, but I'm curious how help-bash feels
> about how I would do this.
> 
> $ cat ./stdin-doubly

What's the purpose of this script?

> $ cat nonsense.txt
> banana
> apple
> 
> $ ./stdin-doubly nonsense.txt
> banana
> apple
> 1
> 4

I don't quite get what you're doing.  You appear to be running the
equivalent of cat "$@" followed by echo 1; echo 4.  If that's actually
what you want, then I'd simplify it down to:

#!/bin/sh
cat "$@"
echo 1
echo 4

If you've got some more subtle purpose in mind, then we need to understand
what it is.  In particular, what your script does *not* do is interleave
the lines of the input file with the numbers, or read a line at a time
from each of two input sources, or reuse the input for each iteration
of the numbers, do anything else that the word "doubly" might imply.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]