1

Sorry if the question is a bit out of place but I've just started learning Linux 2 days and I don't really have any knowledge to get around the problem myself. I was trying out the grep command using this fruit list here and everything was going fine until I went on to try the / expression.

I think I pressed some kind of key combination with the underscore and now most regular expressions seem to be messed up (as well as the file name is now underlined, if that's important in any way). For example when I type:

cat fruits | grep ^ma

I get no results, mandarine and mango don't show up.

When I type:

cat fruits | grep dam*

or

cat fruits | grep dam

Damson doesn't show up. On top of that there is an error cross on the right side of the terminal:

enter image description here

Could anyone explain in simple terms how to get it working again? Thanks a lot!

2 Answers 2

2

Regular Expressions are case sensitive. Your file includes Mandarine with a capital M but you are searching for a line beginning with ma. Try this:

grep '^Ma' fruits

Notice also that I've put the Regular Expression (RE) in single quotes. This stops the shell trying to test it as a word that should be processed - for example, by matching it against files in the current directory.

If you want a case-insensitive comparison, use grep -i. For example,

grep -i 'ma' fruits
2
  • Yes, was just about to comment that. Wondering if he somehow got rid of alias grep=grep -i ...? Commented Aug 25, 2021 at 22:57
  • It could also be a locale thing, but without knowing what they did we can only be guessing Commented Aug 25, 2021 at 23:00
0

You might have borked the bash or dash shell with an accidental keystroke combo. Bash and its counterpart shells, such as dash, are highly configurable programs that translate what you type into what the kernel understands.

Most of the configuration is done with /home/user/.bashrc, but there are many on the fly modifications that require just a key combo. Usually, if you close the terminal window, those modifications are reset.

source .bashrc may, under certain conditions, also work for a reset. See https://linuxhandbook.com/source-command/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .