0

I meet an issue: I want to define a alias in .cshrc.user: alias lsco 'ct lsco -me -avobs -cview | awk '{print $5}''.

But this is not work for me, and this is an error Missing }. when run source .cshrc.user.

The shell in my computer is /bin/tcsh.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
BlackMamba
  • 10,054
  • 7
  • 44
  • 67
  • there is command called `man`, E.g. `man ls` , `man grep`... in your case, it should be `man alias` – Kent Jan 19 '16 at 10:19
  • @Kent Since when shell builtins have a man page? In this case it should be `man csh`.. But try it! I spent my last 15 minutes to figure out how to escape the `$` :) – hek2mgl Jan 19 '16 at 10:34
  • 1
    @hek2mgl the question was tagged with linux + shell, and I spotted the missing `=` in alias statement. didn't notice the `tcsh`, my bad. I don't have experience with `tcsh`. if commands are getting complicated, a function could be considered too. – Kent Jan 19 '16 at 10:39
  • @Kent Probably a function is the way to go here. Good point. – hek2mgl Jan 19 '16 at 10:40
  • @hek2mgl read has a man page... – 123 Jan 19 '16 at 10:40
  • @Kent Looks like [you can't define functions in csh](http://stackoverflow.com/a/13916548/171318) .. – hek2mgl Jan 19 '16 at 10:50
  • @123 That's not the man page of the shell builtin `read`, it's the man page of the glibc function `read()`. How to retrieve help for a shell builtin depends on the shell. In bash you can type `help read`. – hek2mgl Jan 19 '16 at 10:51
  • @hek2mgl cd has a man page. – 123 Jan 19 '16 at 10:52
  • 1
    @123 aren't you just listing commands that have an implementation in coreutils as well as in some shells? – Tom Fenech Jan 19 '16 at 10:53
  • @TomFenech yes i am. – 123 Jan 19 '16 at 10:54
  • 1
    @hek2mgl thx for the info.... now I feel lucky that I don't have to work with tsch... – Kent Jan 19 '16 at 10:57

1 Answers1

2

This will work:

alias lsco 'ct lsco -me -avobs -cview | awk "{print "\$"5}"'
hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • I've seen it written like `"\$5"` too [here](http://www.linuxquestions.org/questions/programming-9/tcsh-escaping-'-or-$-377216/) but I guess it doesn't matter whether the number is inside or outside the quotes. – Tom Fenech Jan 19 '16 at 11:07
  • 1
    @TomFenech Yes, it doesn't matter. It was my first time playing around with `csh`. I need to say that I'm not satisfied with the feature set. – hek2mgl Jan 19 '16 at 11:10