Questions tagged [dash-shell]

A POSIX-compliant shell implementation that aims to be as small as possible. Please use the [hyphen] tag instead of [dash] if your question is about the "-" character.

The Debian Almquist shell (dash), a modern replacement for , is a POSIX-compliant Unix shell. It requires less disk space than , for example, but it is also less feature-rich.

Resources

151 questions
1
vote
4 answers

Bash: get all paths from path

Say I have the path gui/site/junior/profile.py How do I get this?: gui gui/site gui/site/junior Bonus if you tell me how to loop through each path :D
Pithikos
  • 18,827
  • 15
  • 113
  • 136
1
vote
3 answers

How to tokenize string in dash

I read data from a string that is formatted like firstfield|secondfield|thirdfield, in bash I use this construct to achieve this: i="firstfield|secondfield|thirdfield" defaultIFS=$IFS IFS="|" set -- $i arr=( $i…
Robby75
  • 3,285
  • 6
  • 33
  • 52
1
vote
2 answers

Delete unimportant text from file in dash

I have a file with too many lines. Its constructed like: Text Text Text <--!Important Text begins here--> important Text Important Text Important Text <--!Important Text ends here --> Unimportant Text .... <--!Important Text begins…
user3352472
  • 99
  • 1
  • 7
1
vote
2 answers

Dash shell could not able to execute the given command with out double quotes

I am facing a problem with some sample code in an Ubuntu environment with dash shell. When the following block of code is executed in dash shell on Ubuntu Server OS, then I got the output as given below. #!/bin/sh cmd="ls" arg=" -lt" exec "$cmd…
Vinay
  • 13
  • 2
1
vote
1 answer

Shell script, directory is writable strange behavior

Here is -w option description from test's man page : -w FILE FILE exists and write permission is granted And as an example is better than a thousand words : $ ls -ld /home/maxime/.gvfs dr-x------ 2 maxime maxime 0 Aug 5 22:53…
DCMaxxx
  • 2,534
  • 2
  • 25
  • 46
1
vote
3 answers

Build a sed script from specific environment variables

I need to have a very basic template system in shell to port a windows installer to linux. So I can not change the syntax of the template variables. I want to take specific environment variables (starting with $ENV_PREFIX) and build a sed script of…
Thomas Koch
  • 2,833
  • 2
  • 28
  • 36
1
vote
1 answer

shell - Insert a character at different indexes in a string

It will eventually be part of a larger script so it needs to be shell scripted. A simple task in other languages, but I'm having trouble accomplishing it in shell. Basically I have a string and I want to insert a "." at all possible indices within…
Mike Weber
  • 179
  • 1
  • 1
  • 10
1
vote
1 answer

/bin/dash cannot find hostname

I have newly installed a remastered ubuntu 12.10. after installation I ran a script to make a standard user and do some other works. now when I log into the new standard user and open terminal, it only shows a $ mark and doesnt show…
1
vote
3 answers

Assigning dynamic value to variable

how can I assign a dynamic value to variable? The simplest method I know about is by using a function. For example fn(){ VAR=$VAL } VAL=value fn echo $VAR will output value but I want something simpler, like VAR=$VAL VAL=value echo $VAR to…
mYself
  • 191
  • 1
  • 1
  • 11
0
votes
3 answers

Validate an ip in dash (not bash)

I am trying to validate an ip address within a dash script. I've found many ways to achieve the same with bash such as in linuxjournal Basically what is does is a comparision using this: if [[ $ip =~…
aseques
  • 537
  • 4
  • 21
0
votes
1 answer

POSIX sh Redirection

I may be missing something small, but is it possible to achieve this syntax in a POSIX (dash) compliant way: $ ./myApp 2> stderr.txt 1> stdout.txt I know in dash you cannot use >& but have to use 2>&1 but I do not want to do this. I have tons of…
Caleb
  • 870
  • 1
  • 10
  • 21
0
votes
1 answer

Pass the entire content of the variable into a function

I need to convert the contents of the variables as they are into base64. I decided to make a function and pass the content of the variables into it and output it later. So far I have the following #!/bin/dash payload1='{ "currency": "ABC", …
KarlsD
  • 649
  • 1
  • 6
  • 12
0
votes
1 answer

How do I pass command-line arguments to script executed from stdin

These work fine: /bin/dash xyz.sh arg1 curl | /bin/dash - Use case: curl | sh - arg1 Ubuntu executes this as: curl | /bin/dash - arg1 this fails with: sh: 0: Can't open arg1 How do I pass arg1 to curl | /bin/dash?
u15p7fgy863eiq5
  • 205
  • 2
  • 5
0
votes
0 answers

local marked function variables unavailable inside trap function - (d)ash shell

I've read that the local keyword introduces dynamic scoping, meaning the variable defined thus in a function will be visible until the function dies. Hence visible and changeable in other functions that this function calls etc. However it seems that…
ustulation
  • 3,600
  • 25
  • 50
0
votes
1 answer

Why does "echo" ignore its first argument sometimes?

The output of this code seems to depend on the option I give (-n or -a) but I simply don't understand the reason. Here's the portion of the code that doesn't work (just the code itself + outputs): #!/bin/sh FILE="/path/to/some/textfile" [ $# -eq 0…
sirakai
  • 5
  • 3