| Bash | Nushell |
|---|---|
ls |
ls |
ls -la |
ls --long --all or ls -la |
ls -d */ |
ls | where type == dir |
find . -name "*.rs" |
glob **/*.rs or ls **/*.rs |
mkdir -p path |
mkdir path (creates parents automatically) |
touch file |
touch file |
cp src dst |
cp src dst |
cp -r src dst |
cp -r src dst |
mv old new |
mv old new |
rm file |
rm file |
rm -rf dir |
rm -r dir |
cat file |
open --raw file |
head -5 file |
open --raw file | lines | first 5 |
tail -5 file |
open --raw file | lines | last 5 |
wc -l file |
open --raw file | lines | length |
| Bash | Nushell |
|---|---|
> file |
o> file or | save file |
>> file |
o>> file or | save --append file |
> /dev/null |
| ignore |
> /dev/null 2>&1 |
o+e>| ignore |
2>&1 |
o+e>| ... |
cmd | tee log | cmd2 |
cmd | tee { save log } | cmd2 |
| Bash | Nushell |
|---|---|
grep pattern |
where $it =~ pattern or find pattern |
grep -r pattern . |
open --raw file | lines | where $it =~ pattern |
sed 's/old/new/' |
str replace 'old' 'new' |
sed 's/old/new/g' |
str replace --all 'old' 'new' |
awk '{print $1}' |
split column ' ' | get column0 |
sort |
sort |
sort -u |
sort | uniq |
uniq |
uniq |
cut -d: -f1 |
split column ':' | get column0 |
tr '[:upper:]' '[:lower:]' |
str downcase |
| Bash | Nushell |
|---|---|
VAR=value |
let var = "value" |
export VAR=value |
$env.VAR = "value" |
echo $VAR |
$env.VAR |
echo $HOME |
$env.HOME |
echo $PATH |
$env.PATH (list on macOS/Linux) |
echo $? |
$env.LAST_EXIT_CODE |
unset VAR |
hide-env VAR |
${VAR:-default} |
$env.VAR? | default "value" |
export PATH=$PATH:/new |
$env.PATH = ($env.PATH | append "/new") |
FOO=bar cmd |
FOO=bar cmd (same syntax) |
| Bash | Nushell |
|---|---|
cmd1 && cmd2 |
cmd1; cmd2 |
cmd1 || cmd2 |
try { cmd1 } catch { cmd2 } |
$(command) |
(command) |
`command` |
(command) |
command & |
job spawn { command } |
jobs |
job list |
kill %1 |
job kill $id |
type cmd |
which cmd |
man cmd |
help cmd |
bash -c 'code' |
nu -c 'code' |
source script.sh |
source script.nu |
| Bash | Nushell |
|---|---|
if [ cond ]; then ... fi |
if $cond { ... } |
[ -f file ] |
"file" | path exists |
[ -d dir ] |
("dir" | path exists) and ("dir" | path type) == "dir" |
for f in *.md; do echo $f; done |
ls *.md | each { $in.name } |
for i in $(seq 1 10); do ...; done |
for i in 1..10 { ... } |
while read line; do ...; done < file |
open file | lines | each {|line| ... } |
case $x in ... esac |
match $x { pattern => result, ... } |
| Bash | Nushell |
|---|---|
cmd | head -5 |
cmd | first 5 |
cmd | tail -5 |
cmd | last 5 |
\ (line continuation) |
( wrap in parens ) |
read var |
let var = (input) |
read -s secret |
let secret = (input -s) |
| Bash | Nushell |
|---|---|
!! |
!! (inserts, doesn't execute) |
!$ |
!$ |
Ctrl+R |
Ctrl+R |
- Structured vs text: Nushell pipelines pass tables/records, not text streams
- Immutable by default:
letis immutable; usemutwhen needed - No word splitting: Nushell doesn't split variables on whitespace
- No glob expansion in variables: Globs only expand in command position
- Static parsing: Code is parsed before execution; no
evalequivalent - Implicit return: Last expression is the return value; no
echoneeded >is comparison: Useo>orsavefor file redirection