Why when I try to write a function just in one line into .bashrc
file,
list(){ ls -a }
I get error?
bash: /home/username/.bashrc: line num: syntax error: unexpected end of file
but when I write it in multi line it's ok?
list(){
ls -a
}
bashrcscriptssyntax
Why when I try to write a function just in one line into .bashrc
file,
list(){ ls -a }
I get error?
bash: /home/username/.bashrc: line num: syntax error: unexpected end of file
but when I write it in multi line it's ok?
list(){
ls -a
}
Best Answer
Functions in
bash
are essentially named compound commands (or code blocks). Fromman bash
:There's no reason given, it's just the syntax.
Since the list in the one-line function given isn't terminated with a newline or a
;
,bash
complains.