I'm writing a shell script that creates a file with the output from, ls -1F. It contains directories, with, "/" appended to the names. I'm trying to delete those lines in the output file that are flagged with "/". However, I'm running into problems when using sed (because the character I'm searching on is "/"). Does anyone know the correct syntax in sed or an alternative method to accomplish this?
You can use other characters as delimiters in sed:
ls -1F | sed 's#/$##'
you can escape the / character:
ls -1F | sed 's/\/$//'
ls -1F | sed -n '/[^\/]$/p'
I haven't tried other suggestions yet, but your help is much appreciated.
Best Regards All
---------- Post updated at 09:44 AM ---------- Previous update was at 09:36 AM ----------
ls -1F | sed -n '/[^\/]$/p'
---------- Post updated at 09:46 AM ---------- Previous update was at 09:44 AM ----------
ls -1F | sed -n '/[^\/]$/p'