You don't say what operating system or shell this is using. I'm going to guess some distro of Linux and the Bash shell...
Quote:
Originally Posted by
Amit Sura
get below response 'Bad : modifier in $ (").'
Check the filenames that your wildcard expands to. It's likely there's a character in there that when expanded in the gdb command line is giving the shell some grief.
Some rules for typing in shell commands:
1. Always put double quotes around your dollar-sign variables. (It's only wrong about 3 times in 1,000 so you've got a 99.7% chance of being right.
)
2. Use
$(...) instead of
`...`. (Won't matter in this particular case, but it's a good idea for a variety of reasons.)
3. Don't use a bunch of pipes when they're not necessary. (In this case using gdb is
way overkill as the file command will likely give you the right data. Using a command like
set -- $(file "$i") eliminates all of the pipes and only requires a single fork/exec because the set command is builtin to the shell.)
Otherwise I agree with TonyFullerMalv; you need to go back to basics and test out each piece of your command line. In particular, you need to know what data is going into the loop (such as the filenames).