On Sun, Jul 12, 2020 at 02:51:33PM +0000, Ajith R wrote: > 5) execute grep $'\x00A0' .XCompose. All lines from the .XCompose file were > listed.
Bash's $'...' quoting allows several different forms, and you've used the wrong one. The \x is followed by *two* hex digits, to give a single byte. You've got $'\x00' which is a NUL byte. Passing a NUL byte as an argument to a command is equivalent to passing the empty string. So, basically you have run grep '' .XCompose which, as you observed, gives you every line of the file. I would imagine you were trying to pass a Unicode character. If that's the case, you need the \u or \U form instead. grep $'\u00A0' .XCompose Unicode character 00A0 is a non-breaking space. It's not clear whether that was your intention or not. > I noticed that there is $ sign before the search string, which I couldn't > understand. I removed it and re-executed the new grep command grep '\x00A0' > .XCompose. Now it doesn't return the line Uh... you mean you *weren't* trying to grep for non-breaking spaces in your file using bash's $'...' quoting syntax? You're just typing something you found at random on the Internet without understanding it? That's pretty dangerous. <https://mywiki.wooledge.org/Quotes> might be good reading for you at this point. > 6) The command grep "W" .XCompose | tr $'\xc2\xa0' \! returnsĀ > grep "W" .XCompose | tr $'\xc2\xa0' \! The two hex bytes c2 a0 are the UTF-8 encoding of a non-breaking space, so it *does* seem like you're chasing after non-breaking spaces for some reason.... If that's truly your goal, you might also want to pursue configuring your text editor to show them to you. There are various ways to do that, depending on which text editor you use. (I don't even know whether you're in a UTF-8 encoding, though, so who knows whether those are even the correct bytes for an NBSP in your locale. You're better off using \u00A0 instead.)