You are not using $file
anywhere. Try
for file in "$arg"/*.{jpg,jpeg,png} ; do
echo "$file" > z.txt
done
More Related Contents:
- Make Bash handle variables like Batch
- Some troubles with using sed and awk [closed]
- How to loop through file names returned by find?
- How can I pipe stderr, and not stdout?
- Add a new element to an array without specifying the index in Bash
- What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?
- Lookup shell variables by name, indirectly [duplicate]
- How do I use su to execute the rest of the bash script as that user?
- How to iterate over associative arrays in Bash
- Using the RUN instruction in a Dockerfile with ‘source’ does not work
- Why start a shell command with a backslash?
- How to delete files older than X hours
- Bash: Strip trailing linebreak from output
- Find and replace filename recursively in a directory
- Is it possible for bash commands to continue before the result of the previous command?
- How can bash script do the equivalent of Ctrl-C to a background task?
- How to remove (base) from terminal prompt after updating conda
- Stop on first error [duplicate]
- How does bash tab completion work?
- Is mixing getopts with positional parameters possible?
- Running a Bash script over ssh
- How to send email from Terminal?
- How to resolve symbolic links in a shell script
- How to remove double-quotes in jq output for parsing json files in bash?
- Saving current directory to bash history
- Forward function declarations in a Bash or a Shell script?
- Looping through find output in Bash where file name contains white spaces
- Ignoring specific errors in a shell script
- Bash If-statement to check If string is equal to one of several string literals [duplicate]
- How to change a command line argument in Bash?