Results 1 - 25 of about 28 results out of about 112407 pages. (0.06 seconds)
- BashFAQ/005 . . . 11 matches
- ...itionally have [[BashGuide/Arrays#Associative_Arrays|Associative Arrays]] (see also [[BashFAQ/006|FAQ 6]]). This article focuses on indexed arrays as they are the most common type...
- BashFAQ/006 . . . 15 matches
- ...able in POSIX shells.)
4. If the program handles unsanitized user input, it can be [[BashFAQ/048|VERY dangerous]]!
Read [[BashGuide/Arrays]] or [[BashFAQ/005]] for a more in-dep...
- BashFAQ/100 . . . 12 matches
- ...oduction to bash string manipulations and related techniques. It overlaps with the [[BashFAQ/073|Parameter Expansion]] question, but the information here is presented in a more b...
- BashFAQ/001 . . . 11 matches
- ... [[#source|source selection]] below.
If you want to read lines from a file into an [[BashFAQ/005|array]], see [[BashFAQ/005|FAQ 5]].
<<TableOfContents>>
<<Anchor(trimming)>>
==...
- BashFAQ/050 . . . 8 matches
- ...ant to pass options if the runtime data needs them ===
You can use the `${var:+..}` [[BashFAQ/073|parameter expansion]] for this:
{{{
ping -q ${count:+"-c$count"} -- "$HOSTNAME"
...
- BashFAQ/040 . . . 6 matches
- ...{{{eval}}} for that purpose, but the cleanest way to achieve this goal is to use an [[BashFAQ/005|array]].
{{{#!highlight bash
# Bash
unset -v m; i=0
words=(apple banana cherry "...
- BashFAQ/004 . . . 6 matches
- ...ob` and `dotglob` options (which change the behaviour of [[glob|globbing]]), and an [[BashFAQ/005|array]]:
{{{#!highlight bash
# Bash
shopt -s nullglob dotglob
files=(*)
(( ${#fi...
- BashFAQ/044 . . . 5 matches
- ...cho $((100*(++i)/n))
done
)
}}}
Here's an explanation of what it's doing:
* An [[BashFAQ/005|array]] named {{{files}}} is populated with all the files we want to process.
* ...
- BashFAQ/026 . . . 5 matches
- ...ay[rand]} array[rand]=$tmp
done
}
}}}
This function shuffles the elements of an [[BashFAQ/005|array]] in-place using the [[http://en.wikipedia.org/wiki/Knuth_shuffle|Knuth-Fis...
- BashFAQ/025 . . . 5 matches
- ..."$@"`"
}}}
In addition, bash and ksh93 treat the set of positional parameters as an [[BashFAQ/005|array]], and you may use [[BashFAQ/073|parameter expansion]] syntax to address th...
- BashFAQ/118 . . . 4 matches
- ...r, or reverse an array? ==
First note that the concept of ''order'' applies only to [[BashFAQ/005|indexed arrays]], not associative arrays. The answers would be simpler if there ...
- BashFAQ/096 . . . 4 matches
- ..., bash provides a way to protect such things safely: `printf %q`. Together with an [[BashFAQ/005|array]] and a loop, we can write a wrapper:
{{{
# Bash 2.05b and up
# Your accou...
- BashFAQ/073 . . . 4 matches
- ...ers#Parameter_Expansion|Bash Guide]] includes an introduction for beginners.
* The [[BashFAQ/100|string manipulation tutorial]] is a more in-depth tutorial with additional exampl...
- BashFAQ/095 . . . 3 matches
- ...he `-exec` only passes it one name.)
The most general alternative is to use a Bash [[BashFAQ/005|array]] and a loop to process the array in chunks:
. {{{
# Bash
files=(/usr/inc...
- BashFAQ/094 . . . 3 matches
- ...s is the workaround for lines being split unpredictably. For example, using a Bash [[BashFAQ/005|array]] df_arr:
{{{
~$ read -d '' -ra df_arr < <(LC_ALL=C df -P /); echo "${d...
- BashPitfalls . . . 25 matches
- ...` loop body) is executed in the current shell. You can set variables and have them [[BashFAQ/024|persist after the loop ends]].
The other option, available in [[BashFAQ/061|Bash...
- ProcessManagement . . . 10 matches
- ... file descriptors have been redirected so they aren't holding the terminal open, or [[BashFAQ/063|the ssh client may hang]].
== I'm trying to kill -9 my job but blah blah blah......
- BashGuide/Parameters . . . 9 matches
- ...al/bashref.html#Shell-Variables|Shell Variables]]
----
. '''In the FAQ''': <<BR>> [[BashFAQ/013|How can I concatenate two variables? How do I append a string to a variable?]] <<...
- Bashism . . . 8 matches
- ...h; present in zsh. ||
||file slurp ||`$(< file)` ||`$(cat file)` ||Or read the file [[BashFAQ/001|line by line]]. ||
== Expansions ==
* Brace Expansion, eg `{a,b,c}` or `{1..10...
- BashGuide/Arrays . . . 6 matches
- ...software/bash/manual/bashref.html#Arrays|Arrays]]'''
----
. '''In the FAQ: <<BR>> [[BashFAQ/005|How can I use array variables?]] <<BR>> [[BashFAQ/006|How can I use variable vari...
- ArithmeticExpression . . . 6 matches
- ...h only. You can't do floating point math in Bash; if you need that capability, see [[BashFAQ/022|Bash FAQ #22]].
/!\ The `$[ ]` syntax is [[http://wiki.bash-hackers.org/syntax/e...
- Arguments . . . 6 matches
- ... This ''zeroth'' argument is the name that we wish to give the process. It's only [[BashFAQ/028|vaguely defined]] what exactly that means and what it's used for, and it's irrele...
- DontReadLinesWithFor . . . 5 matches
- ...file. This is clumsy and inefficient at best, and fails in many cases. You should [[BashFAQ/001|use a while loop]] instead. Here is why.
First, the right way:
{{{
$ cat afile...
- WordSplitting . . . 4 matches
- ...}}}
`"$@"` causes each positional parameter to be expanded to a separate word; its [[BashFAQ/005|array]] equivalent likewise causes each element of the array to be expanded to a ...
- BashSheet . . . 3 matches
- ...Parameters#Parameter_Expansion|the BashGuide's section on Parameter Expansion]] and [[BashFAQ/073]].
* `"$var"`, `"${var}"`
. '''Expand the value contained within the paramete...