Skip to the content ForoHackers
Log inJoin

Bash has discovered a photograph called *.jpg. I would quite like to see it.

DebuggingShell scripting
#15375 · · Quote · Report

Tiny personal script, nothing clever: for f in *.jpg; do printf 'photo: %s\n' "$f"; done. In a directory with two pictures it prints both names. In an empty directory I get a solemn line reading photo: *.jpg. There is no bloody photograph. Where did Bash get it?

#15668 · · Quote · Report

If no file matches the pattern, Bash normally leaves the pattern text alone. You're printing the original argument. This is as close as a star has ever come to taking its own picture.

#15669 · · Quote · Report

Sorted in this Bash script with shopt -s nullglob before the loop. Empty directory, no lines. Kept the quotes around "$f"; one of the real pictures is called nice hinge.jpg and it's a very nice hinge.

#15670 · · Quote · Report

May we see the hinge?

#15671 · · Quote · Report

My partner says this is how the garage forum thing started and I am not allowed to do it again.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply