2026-11-05 13:50 UTC
Any way to make commands in bash scripts in the Linux terminal accept characters with accents such as 'ú'?
#!/bin/bash
# name of the script is SCAN.bash
scanimage -d [device] --format=png -p -o $1
I have tried ' ‘, " " and to escape it with \
./SCAN 'július.png'
./SCAN "július.png"
./SCAN j\úlius.png
But it throws argument without option. It works fine if I type it out instead of scripting.
The target language is Hungarian and I have generated the necessary locale.
Replies (6)
-
@imsufferableninja@sh.itjust.works 2026-11-05 13:56
Try exporting LC_ALL= at the top of the script
-
@istdaslol@feddit.org 2026-11-05 14:00
It does, bash uses your locale and if the umlauts are displayed correctly it is set to utf-8 or similar. Your other optiones aren’t parsed correctly ` #!/usr/bin/env bash filename=“$1” angle=“$2” resolution=“$3” `
-
@Malix@sopuli.xyz 2026-11-05 14:01
Put the $1 in quotes in the script. -o “$1” ?
-
@SomeRandomNoob@discuss.tchncs.de 2026-11-05 14:02
ahhh … found your problem: Put double quotes around the $1 in the bash script: scanimage -d [device] --format=png -p -o “$1”
-
@imsufferableninja@sh.itjust.works 2026-11-05 14:04
If there is whitespace in the filename, when you pass it to the script you need to escape it or wrap it in quotes. And then you need to put quotes around the variable in the script that reads the parameters
-
@django@discuss.tchncs.de 2026-11-05 14:31
Shellcheck can help spotting such mistakes: www.shellcheck.net