Alias to display file names of all hidden files in current directory not working
Hello Linux gurus,
I'm having some trouble in my attempt to create an alias for the following set of commands that shows the file name of all hidden files in the current directory:
ls -la | awk '$9 ~ /^\./ {print $9}'
It works fine when I type it in the command line. But when I put it in an alias like this:
alias .f='ls -la | awk '$9 ~ /^\./ {print $9}''
I encounter the following error message when I invoke the alias:
awk: fatal: cannot open file `/^./' for reading (No such file or directory)
I believe the placement of the first pair of single quotes is causing the error, as the shell treats everything in it as one argument and the regex pattern "/^./" as the argument for file name for awk. But I've no idea how to fix the broken syntax. I've tried using back-ticks, double quotes, all to no avail.
Any help is greatly appreciated.
|