Sample Header Ad - 728x90

Use of ^ as a shell metacharacter

20 votes
3 answers
1628 views
I wrote a small script today which contained grep -q ^local0 /etc/syslog.conf During review, a coworker suggested that ^local0 be quoted because ^ means "pipe" in the Bourne shell. Surprised by this claim, I tried to track down any reference that mentioned this. Nothing I found on the internet suggested this was a problem. However, it turns out that the implementation of bsh (which claims to be the Bourne shell) on AIX 7 actually has this behaviour: > bsh $ ls ^ wc 23 23 183 $ ls | wc 23 23 183 None of the other "Bourne shell" implementations I tried behave this way (that is, ^ is not considered a shell metacharacter at all). I tried sh on CentOS (which is really bash), and sh on FreeBSD (which is not bash). I don't have many other systems to try. Is this behaviour expected? Which shells consider ^ to be a pipe metacharacter?
Asked by Greg Hewgill (7113 rep)
Dec 9, 2013, 12:43 AM
Last activity: Mar 29, 2024, 08:44 AM