Skip to main content
edited tags
Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
Post Undeleted by Mathew
Post Deleted by Mathew
Source Link
Mathew
  • 243
  • 2
  • 11

awk inside function causing errors

I'm trying to add the following to my .bashrc:

cpu_info() { top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}' } 

but bash is telling me:

bash: .bashrc: line 131: syntax error near unexpected token `(' bash: .bashrc: line 131: ` top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}'' 

the command works fine in the terminal, not sure why its breaking in my bash script

any ideas?