FISH-FOR-BASH-USERS(1) fish-shell FISH-FOR-BASH-USERS(1) (NAME) fish-for-bash-users - (DESCRIPTION) bash ( zsh ksh) . fish POSIX . - () (globs) . . (COMMAND SUBSTITUTIONS) fish $(command) (command) `command`. $IFS (newline) . string split, string split0 string collect . . : for i in (find . -print0 | string split0) . (VARIABLES) fish VAR=VAL declare unset export set . set (scope) (export) : # Define $PAGER *g*lobal and e*x*ported, # so this is like ``export PAGER=less`` set -gx PAGER less # Define $alocalvariable only locally, # like ``local alocalvariable=foo`` set -l alocalvariable foo : set -e PAGER VAR=VAL : PAGER=cat git log fish (word splitting) . ( ) bash . [1] bash : > foo="bar baz" > printf '"%s"\n' $foo # will print two lines, because we didn't double-quote # this is word splitting "bar" "baz" fish : > set foo "bar baz" > printf '"%s"\n' $foo # foo was set as one element, # so it will be passed as one element, so this is one line "bar baz" <<>> ( <<>> ) ( "${var[@]}" bash): > set var "foo bar" banana > printf %s\n $var foo bar banana : echo $list[5..7] set : # Set lines to all the lines in file, one element per line set lines (cat file) : > set numbers 1 2 3 (seq 5 8) 9 > printf '%s\n' $numbers 1 2 3 5 6 7 8 9 = set - set foo = bar "foo" : "=" "bar". set foo=bar . (Shell variables) . [1] zsh ( SH_WORD_SPLIT ). (VARIABLE DEFAULTS) fish ${my_variable:-fallback} . : # Ensure XDG_CONFIG_HOME is set or use a default value set -q XDG_CONFIG_HOME || set XDG_CONFIG_HOME $HOME/.config # now use XDG_CONFIG_HOME as normal (WILDCARDS / GLOBS) fish * ** ( ?) . ( failglob bash) for set count (VAR=* command) ( nullglob bash). : set foo "*" echo $foo . . ** . setopt globstar bash . bash (symlinks) (natural sort) . 1 01 . (Wildcards) . (QUOTING) fish : "" ( ) '' ( ). . $'' : > echo a\nb a b (Quotes) . (STRING MANIPULATION) fish ${foo%bar} ${foo#bar} ${foo/bar/baz} . string . "bar" "baz": > string replace bar baz "bar luhrmann" baz luhrmann : > string split "," "foo,bar" foo bar (Regex) grep: > echo bababa | string match -r 'aba$' aba (padding): > string pad -c x -w 20 "foo" xxxxxxxxxxxxxxxxxfoo : > string lower Foo foo > string upper Foo FOO (trim) ( ). (SPECIAL VARIABLES) bash fish: o $* $@ $1 : $argv o $?: $status o $$: $fish_pid o $#: count $argv o $!: $last_pid o $0: status filename o $-: status is-interactive status is-login (PROCESS SUBSTITUTION) fish <(command) (command | psub) . >(command) . (bashisms) . : source (command | psub) : command | source source (stdin) . (HEREDOCS) fish <> < . : cat < : printf %s\n "some string" "some more string" : echo "some string some more string" # or if you want the quotes on separate lines: echo "\ some string some more string\ " . <> : 1. . [2] 2. . 3. (stdin) . () : echo "foo" | cat : cat < (stdin) . - . : echo "xterm rxvt-unicode" | pacman --remove - # is the same as (the `-` makes pacman read arguments from stdin) pacman --remove xterm rxvt-unicode : # This "-" is still necessary - the heredoc is *also* passed over stdin! pacman --remove - << EOF xterm rxvt-unicode EOF (syntactic sugar) . . : { cat packages1; echo fish; } | pacman --sync - [2] "EOF" "THISISTHEEND" . <<- ( ) . ( ) : cat << "EOF". (TEST - [, [[) fish test [ POSIX . [[ test == = . () . set -q (set -q foo[2]). (ARITHMETIC EXPANSION) fish $((i+1)) math : math $i + 1 bash () : > math 5 / 2 2.5 : > math cos 2 x pi 1 math . () ( ) : > math '(5 + 2) * 4' * x * (glob) . (PROMPTS) fish $PS1 $PS2 . fish_prompt fish_mode_prompt vi . fish_right_prompt . bash : # <$HOSTNAME> <$PWD in blue> PS1='\h\[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] ' fish : function fish_prompt set -l prompt_symbol '$' fish_is_root_user; and set prompt_symbol '#' echo -s (prompt_hostname) \ (set_color blue) (prompt_pwd) \ (set_color yellow) $prompt_symbol (set_color --reset) end : o fish set_color . RGB ( set_color 5555FF ). o \h . \h prompt_hostname . o fish fish_vcs_prompt (git mercurial svn) prompt_pwd $PWD ( ~ ). type fish_prompt . fish $PS2 . (BLOCKS AND LOOPS) fish . end : for i in 1 2 3; do echo $i done # becomes for i in 1 2 3 echo $i end while true; do echo Weeee done # becomes while true echo Weeeeeee end { echo Hello } # becomes begin echo Hello end if true; then echo Yes I am true else echo "How is true not true?" fi # becomes if true echo Yes I am true else echo "How is true not true?" end foo() { echo foo } # becomes function foo echo foo end # (bash allows the word "function", # but this is an extension) fish until . while not while ! . (SUBSHELLS) Bash <<>> (subshell) . . : # A list of commands in `()` parentheses (foo; bar) | baz # Both sides of a pipe foo | while read -r bar; do # This will not be visible outside of the loop. VAR=VAL # This background process will not be, either baz & done fish . . ( set -l) fish -c 'your code here' . () {} . fish begin; end : (foo; bar) | baz # when it should really have been: { foo; bar; } | baz # becomes begin; foo; bar; end | baz while read : foo | while read bar set -g VAR VAL baz & end echo $VAR # will print VAL jobs # will show "baz" bash `command` $(command) fish $(command) (command) . Bash . (BUILTINS AND OTHER COMMANDS) fish . bash : o string - (${i%foo} ) grep sed . o math - $((i + 1)) ( ) . o argparse - bash getopt ( zsh zparseopts ). o count - $# wc . o status - . $- $BASH_LINENO . o seq(1) - {1..10} . seq . (OTHER FACILITIES) Bash set -x set -o xtrace . fish fish_trace . (profile) fish --profile - fish(1) . (AUTHORS) (fish-shell developers) (COPYRIGHT) (fish-shell developers) (SEE ALSO) fish(1), bash(1), fish-doc(1) : 4.9 2026-09-07 FISH-FOR-BASH-USERS(1)