Questions tagged [ash]

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).

172 questions
87
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,421
  • 4
  • 15
  • 20
66
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,177
  • 13
  • 43
  • 59
36
votes
3 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
  • 1,754
  • 1
  • 15
  • 19
34
votes
1 answer

How to add a new line in the bash string?

The new line \n is not taken account in the shell strings root@toto:~# str="aaa\nbbbb" root@toto:~# echo $str aaa\nbbbb expected result: root@toto:~# echo $str aaa bbbb How to add a new line in the string?
developer
  • 4,188
  • 5
  • 33
  • 50
23
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
  • 35,883
  • 48
  • 140
  • 238
22
votes
14 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
  • 35,883
  • 48
  • 140
  • 238
18
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
  • 1,920
  • 1
  • 17
  • 21
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
  • 525
  • 2
  • 9
10
votes
1 answer

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
  • 2,852
  • 3
  • 25
  • 44
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
  • 37,606
  • 5
  • 69
  • 77
7
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,008
  • 2
  • 14
  • 30
7
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
  • 136
  • 1
  • 2
  • 12
7
votes
1 answer

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,421
  • 4
  • 15
  • 20
6
votes
8 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
  • 307
  • 2
  • 3
  • 11
5
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
  • 2,774
  • 6
  • 39
  • 60
1
2 3
11 12