Answer the question
In order to leave comments, you need to log in
List of files without extensions but at the same time display hidden files (so that the dot remains)?
Here today someone asked the question: "
How to display file names without extensions, but at the same time display hidden files (so that the dot remains)?
" Any questions?
I also wondered how this can be solved, but even though it’s simple, but quickly it didn’t work
either to write code or google the answer.
I’ve been familiar with linux | bash for a long time (I’m just learning)
Enough lyrics, let’s get to the question: ls - a will give a listing of directories with hidden files,
but how to exclude directories from this list?
with regexp I don’t understand anything at all (I did it in notepad++ in a minute) I
tried ls -a | awk '/(^.+?)(\..+$) /{print $1}'
this solves it in notepad++, but how to translate it into the linux console?
PS
in this case, everything that comes after the last / right dot in the file name is considered an extension, of
course, excluding files starting with a dot.
PS
1) solution:
find -maxdepth 1 -type f -printf "%f\n" | sed -r 's/^(.+)\.[^.]+$/\1/'
Answer the question
In order to leave comments, you need to log in
Why is everything so complicated for you.
Output everything without extension, but with dots
Remove directories
Another option is to ignore files where there is a dot not at the beginning of the file.ls -FA --ignore='?*.*' | grep -v "/"
Can you find out what exactly the function does?
sed -r 's/^(.+)\.[^.]+$/\1/'?
Thank you, I seem to have read the man, but somehow it "passed by the checkout" ls -FA | grep -v "/"
now I will know/use,
and with extensions --ignore='*.???' - alas, not a universal option,
because. it can be any number of characters.
but this will be just right ㋛
ls -FA | grep -v "/" | sed -r 's/^(.+)\.[^.]+$/\1/'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question