A shell(ash) written by Kenneth Almquist and released to the comp.sources.unix Usenet news group on May 30th 1989. It has features similar to the Bourne shell(sh). Its many derivatives include the system shell on; Debian (dash), FreeBSD (sh), NetBSD (sh) and the default shell in Busybox (ash).
Questions tagged [ash]
189 questions
7
votes
1 answer
How to keep program running in background in ash shell
I need to SSH to an embedded device, launch a background program, then disconnect and keep the background process running. The problem is that the embedded device is using the ash shell (NOT bash or anything else), so nohup and screen are NOT…

Marc
- 3,386
- 8
- 44
- 68
6
votes
3 answers
How to match regexp with ash?
Following code works for bash but now i need it for busybox ash , which apparrently does not have "=~"
keyword="^Cookie: (.*)$"
if [[ $line =~ $keyword ]]
then
bla bla
fi
Is there a suitable replacement ?
Sorry if this is SuperUser question,…

user3155036
- 147
- 1
- 3
- 10
5
votes
1 answer
How to know the parent process if the child is launched in background and the parent is already exited
I have a child process running in foreground and his father is already exited.
the proc/$pid/stat file does not contain any more the parent pid if the parent is already exited and it display 1 instead of the origin parent pid
linux$cat…

MOHAMED
- 41,599
- 58
- 163
- 268
5
votes
3 answers
Check if a function exists before executing it in shell
I want to check if a function exist or not before executing it in the shell script.
Does script shell support that? and how to do it?

MOHAMED
- 41,599
- 58
- 163
- 268
4
votes
7 answers
Extracting beginning alphabets of a string in bash/ash
How can I extract the beginning alphabetic letters from a string?
I want to extract alphabets occurring in the beginning before I hit the first non-alphabetic character.
e.g. If the input string is abcd045tj56 the output should be abcd
Similarly,…

Deepali Joshi
- 61
- 3
4
votes
4 answers
How to write a for loop to perform an operation N times in the ash shell?
I'm looking to run a command a given number of times in an Alpine Linux docker container which features the /bin/ash shell.
In Bash, this would be
bash-3.2$ for i in {1..3}
> do
> echo "number $i"
> done
number 1
number 2
number 3
However, the same…

Kurt Peek
- 52,165
- 91
- 301
- 526
4
votes
3 answers
How can I store a list of quoted strings in a variable in Bourne shell? (without Bash arrays)
Using Bash's arrays, I can store a list into an array variable and iterate over the elements while keeping quoted strings containing spaces or special characters together:
LIST=(--foo --bar --baz "test 1 2 3")
for item in "${LIST[@]}"; do
echo…

Dan Lenski
- 76,929
- 13
- 76
- 124
4
votes
3 answers
How to make a return from a child function cause a return to the parent function?
I have a parent function and child function:
parent() {
child aa1 bb1 cc1
child aa2 bb2 cc2
child aa3 bb3 cc3
child aa4 bb4 cc4
}
child() {
....
if [ some error reason ]; then return 1; fi
...
}
How to make the return 1 (of the…

MOHAMED
- 41,599
- 58
- 163
- 268
3
votes
1 answer
How to suspend a backgrounded shell with a script?
Unfortunately I don't have a suspend command (busybox/ash). But I can use kill -STOP $$ to return from a backgrounded shell (sh &) to the parent shell (and fg later).
But instead of typing this long kill-command I would like to write a script (named…

deetee
- 75
- 1
- 7
3
votes
1 answer
Return string value * is expanded upon return of call
I am building a script running in #/bin/sh on a modem running a variant of openwrt:
root@Inteno:~# ls -l /bin/sh
lrwxrwxrwx 1 root root 7 Oct 15 2014 /bin/sh -> busybox
The script is gathering and presenting data. I have run…

Ruben Andre Sviggum
- 53
- 8
3
votes
1 answer
Ash shell - How to do while loop inside a function?
For a specific reason I have to do an infinite loop inside a function and then run the function as a daemon,
#!/bin/sh
lol(){
while true
do
echo "looping..."
sleep 2
done
}
lol() &
that script doesn't work, it gives me the following…

Lin
- 1,771
- 6
- 17
- 21
3
votes
5 answers
Get current playing file in MPlayer slave mode
Problem: I can't find any way to reliably get the current playing file in an MPlayer playlist.
Here is how far I have gotten. This working ash script monitors a text file with the path to the current playlist. When I update the file, the script…

fodder
- 181
- 3
- 10
3
votes
1 answer
Infinite loop script in openwrt?
I was over on the openwrt forum and I had a user help me with making a script, but I am having trouble with it.
Basically I have a openwrt router with a microphone attached, and I want to record throughout the day, automatically. He told me to try…

andyADD
- 610
- 1
- 6
- 20
2
votes
2 answers
wait command behaves differently on Bash and Ash
Given the following simple snippet, saved in a file named test.sh:
sleep 3 && exit 50&
echo "Wait for ${!} for the first time."
wait "${!}"
echo "Exit code is: ${?}"
sleep 1 # this line makes a difference
echo "Wait for ${!} for the second…

Livy
- 631
- 4
- 15
2
votes
0 answers
Trap on DEBUG signal for the Alpine Shell (ash)?
With the bash shell, you can install a trap on the synthetic DEBUG signal. This is useful and will execute your function or bit of code on every shell command, not so in ash, however. E.g.
$ trap 'echo hi' DEBUG
-ash: trap: DEBUG: invalid signal…

Ilias Karim
- 4,798
- 3
- 38
- 60