Using ls, how to list files without printing the extension (the part after the dot)?
using sed?
ls -1 | sed -e 's/\..*$//'
ls | while read fname
do
echo ${fname%%.*}
done
Try that.
ls -a | cut -d "." -f 1
man (1) cut
Very handy, the -d switch defines the delimiter and the -f which field you want.
EDIT: Include riverfall's scenario is also piece of cake as cut can start also from the end, though the logic is somewhat different. Here an example with a bunch of files with random names, some with two dots, some with a single dot and some without extension:
runlevel0@ubuntu:~/test$ ls
test.001.rpx test.003.rpx test.005.rpx test.007.rpx test.009.rpx testxxx
test.002.rpx test.004.rpx test.006.rpx test.008.rpx test_nonum test_xxx.rtv
runlevel0@ubuntu:~/test$ ls | cut -d "." -f -2
test.001
test.002
test.003
test.004
test.005
test.006
test.007
test.008
test.009
test_nonum
testxxx
test_xxx.rtv
Using the minus before the field number makes it eliminate all BUT the indicated fields (1,2 in this case) and putting it behind makes it start counting from the end.
This same notation can be used for offset and characters besides of fields (see the man page)