6

cat is a program that simply takes its input stream, or a file, and prints it to standard output. You cannot cat a directory, that doesn't make sense. If you just want to see the names of all first level subdirectories of a given directory, you can use echo which simply prints what you give it: $ for dir in foo/*/; do echo "$dir"; done foo/dir1/ ...


4

Yes, * is called a "wildcard" and it's mostly used as a symbol to represent one or more characters. Consider your example (with added command from me): ls /home/renga/i* where the /home/renga directory is like this internal inspiration auth unknown liar i* Thus your command will give an output like this: /home/renga/internal /home/renga/...


3

You want to insert the date before the dot, so you need to split the name: find . -maxdepth 1 -type f -name '*.*' -exec sh -c 'mv -- "$0" "${0%.*}"-$(date +%Y%m%d).${0##*.}' {} \; ${0%.*} takes the name up to the . and ${0##*.} gives you the extension (with the date in between). -maxdepth 1 limits the files to the current directory (...


2

This seems like an odd requirement, but to extract digits from arbitrary filenames, you could use parameter expansion to remove anything from the filename that's not a digit: for f in * do printf '%s\n' "${f//[^[:digit:]]/}" done


2

It finds nothing because the -name test takes a shell glob and globs don't know \r. Assuming your Cygwin shell supports $' ' notation, you could do: find . -name '*'$'\r''*' So, to delete, you can do: find . -name '*'$'\r''*' -delete Or, if your find doesn't have the -delete action, use: find . -name '*'$'\r''*' -exec rm {} + The -regex test might seem ...


1

How to rename files to their hashes? while IFS=' ' read <&3 -r hash fileName; do echo mv -v -- "${fileName#\*}" "${hash}"; done 3< infile.txt How to rename hashes to their filenames? while IFS=' ' read <&3 -r hash fileName; do echo mv -v -- "${hash}" "${fileName#\*}"; done 3< infile.txt ...


Only top voted, non community-wiki answers of a minimum length are eligible