#! /usr/bin/bash
for var in "$@"
do
echo $var
done
simple shell script which displays each of the command line arguments, one at a time and stops displaying command line arguments when it gets an argument whose value is “stop”.?
#! /usr/bin/bash
for var in "$@"
do
echo $var
done
simple shell script which displays each of the command line arguments, one at a time and stops displaying command line arguments when it gets an argument whose value is “stop”.?
IIUC, try this:
#!/bin/bash
for var in "$@"
do
if [[ "$var" == 'stop' ]]; then
exit 0
else
echo "$var"
fi
done
Process args with a while loop:
#!/usr/bin/env bash
while test -n "$1"; do
test "$1" != 'stop' && echo "$1" && shift || break
done