This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# The logic in the getpos function is stolen from | |
# http://stackoverflow.com/a/2575525 | |
# Pass "row" or "col" as an argument to get their positions | |
getpos () | |
{ | |
exec </dev/tty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for I in <(ls -1ld /) <(ls -l1d /) | |
do | |
exec 3<"$I" || exec 3<&-; | |
echo is:$I | |
o=$(cat 0<&3) | |
echo $o | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 10 | |
while ((x == 1)) | |
do | |
echo foo | |
echo bar | |
done | |
for ((i=0; i < 10; i++)) | |
do | |
if ((i % 2 == 0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tab: 8 | |
# Bourne/Korn/Horstmann | |
while ((x == 1)) | |
do echo foo | |
echo bar | |
done | |
for ((i=0; i < 10; i++)) | |
do if ((i % 2 == 0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn() { | |
((1,1,1)) | |
a=(f o o) | |
} | |
typeset -fp fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn () { | |
function fn ((1)) | |
function fn ((1)) 2>/dev/null | |
} | |
functions fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in {1..10} | |
do | |
bash -c ' | |
TIMEFORMAT=%3R | |
time ( | |
printf "%d\n" {1..10000} \ | |
| while read; do echo $REPLY done > /dev/null; | |
) | |
' | |
done \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
for i | |
in {0..9} | |
do | |
echo "$i" | |
done | |
# | |
case "$p" | |
in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% printf '%d\n' {1..10000} | { time a=$(</dev/stdin) ; echo "$a"; } | wc -c | |
real 0m0.027s | |
user 0m0.004s | |
sys 0m0.004s | |
48894 | |
% printf '%d\n' {1..10000} | { time read -rd '' a; echo "$a"; } | wc -c | |
real 0m0.041s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST_A=( | |
'1a' | |
'2a' | |
'3a' | |
) | |
TEST_B=( | |
'1b' | |
'2b' | |
'3b' |
OlderNewer