How can I remove the extension of a filename in a shell script?

What’s wrong with the following code? name=”$filename | cut -f1 -d”.” As is, I get the literal string $filename | cut -f1 -d’.’, but if I remove the quotes I don’t get anything. Meanwhile, typing “test.exe” | cut -f1 -d’.’ in a shell gives me the output I want, test. I already know $filename has … Read more

How to make the ‘cut’ command treat same sequental delimiters as one?

I’m trying to extract a certain (the fourth) field from the column-based, ‘space’-adjusted text stream. I’m trying to use the cut command in the following manner: cat text.txt | cut -d ” ” -f 4 Unfortunately, cut doesn’t treat several spaces as one delimiter. I could have piped through awk awk ‘{ printf $4; }’ … Read more