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
113
votes
2 answers
What do $? $0 $1 $2 mean in shell script?
I often come across $? $0 $1 $2 etc.... in shell scripting, what I know is that $? returns the exit status of the last command
echo "this will return 0"
echo $?
but what do the others do? what are they called and is there more? perhaps like $3 $4…

Lin
- 1,771
- 6
- 17
- 21
80
votes
2 answers
does linux shell support list data structure?
this question is not the same as Does the shell support sets?
i know lots of script language support list structure, such as python, python, ruby, and javascript, so what about linux shell?
does shell support such syntax?
for i in list:
do
…

hugemeow
- 7,777
- 13
- 50
- 63
59
votes
4 answers
How to get /etc/profile to run automatically in Alpine / Docker
How can I get /etc/profile to run automatically when starting an Alpine Docker container interactively? I have added some aliases to an aliases.sh file and placed it in /etc/profile.d, but when I start the container using docker run -it…

Jeff Kilbride
- 2,614
- 1
- 20
- 21
35
votes
1 answer
How can I add a new line in a Bash string?
The new line \n is not taken account in the shell strings:
str="aaa\nbbbb"
echo $str
Output:
aaa\nbbbb
Expected result:
aaa
bbbb
How can I add a new line in the string?

developer
- 4,744
- 7
- 40
- 55
31
votes
3 answers
All newlines are removed when saving cat output into a variable
I have the following file
linux$ cat test.txt
toto
titi
tete
tata
Saving the cat output into a variable will discard the newlines
linux$ msgs=`cat test.txt`
linux$ echo $msgs
toto titi tete tata
How to keep the output containing the newlines in…

MOHAMED
- 41,599
- 58
- 163
- 268
29
votes
18 answers
How to reverse a list of words in a shell string?
I have a list of words in a string:
str="SaaaaE SeeeeE SbbbbE SffffE SccccE"
I want to reverse it in order to get
"SccccE SffffE SbbbbE SeeeeE SaaaaE"
How I can do that with ash?

MOHAMED
- 41,599
- 58
- 163
- 268
22
votes
5 answers
How does one reboot from an ash shell?
How does one reboot from an ash shell?
I have an Ubuntu system that is currently bricked for some reason (not pertinent for this question), which means I boot into a BusyBox ash shell. But the exit command does squat, and reset is irrelevant. There…

Urhixidur
- 2,270
- 2
- 19
- 24
15
votes
2 answers
how to replace "/" in a POSIX sh string
To replace substring in the bash string str I use:
str=${str/$pattern/$new}
However, I'm presently writing a script which will be executed with ash.
I have a string containing '/' and I want to use the above syntax inorder to replace the '/' in my…

Anis_Stack
- 3,306
- 4
- 30
- 53
10
votes
1 answer
How POSIX compliant is "/path/file/.."?
I wanted to change current directory into shell script into directory, containing specific regular file. I found that following trick works in mksh and busybox sh:
path=/path/to/regular/file
cd $path/..
but not in GNU Bash:
bash: cd:…

KAction
- 587
- 2
- 10
10
votes
2 answers
Docker Alpine linux running 2 programs
I am trying to create docker image with alpine linux, which after run will create container with 2 running programs. This 2 (in my opinion - I don't know docker well) can't be separated because first program changes the seconds configuration file…

Zolo
- 176
- 1
- 2
- 14
10
votes
1 answer
Android adb shell - ash or ksh?
The Android online documentation Android Debug Bridge says "Adb provides an ash shell". Sure enough, if I adb shell to an AVD emulator I get ash which is basically a cut-down Bourne shell.
However, if I connect to a couple of remote devices, one…

cdarke
- 42,728
- 8
- 80
- 84
9
votes
2 answers
How to separate fields with pipe character delimiter
I know this question has already been asked but no of the solution I've found worked for me! I have a program that has an output like this:
COUNT|293|1|lps
I'm interested in having the second field however no one of these tries worked:
./spawn 1 |…

morandg
- 1,066
- 3
- 14
- 30
8
votes
2 answers
How to use array in ash?
For some reason, I can't use bash to build my script, the only way to do it is with ash, I have this sms auto responder script, each reply must be at max 160 chacters long, it looks like this:
#!/bin/sh
reply="this is a reply message that…

Lin
- 1,771
- 6
- 17
- 21
8
votes
9 answers
How to run a script in background (linux openwrt)?
I have this script:
#!/bin/sh
while [ true ] ; do
urlfile=$( ls /root/wget/wget-download-link.txt | head -n 1 )
dir=$( cat /root/wget/wget-dir.txt )
if [ "$urlfile" = "" ] ; then
sleep 30
continue
fi
url=$( head…

orlea
- 547
- 2
- 5
- 13
7
votes
0 answers
How to use binaries installed with `apk` `--force-broken-world` flag
I've been reading the man pages for apk add, but I don't fully understand how to use the --force-broken-world flag.
I was trying to install Python 2.7.6 into an Alpine image, but I got the following error.
$ docker run --rm -it alpine:latest apk add…

Zak
- 12,213
- 21
- 59
- 105