Live data from Hacker News

I always forget the argument order of the `ln -s` command

reddit.com

51–60 of 127 posts

Re: I always forget the argument order of the `ln -s` command

#51
post #34

I also occasionally forget the -s, and really wish it was the default since I'm almost always creating a symbolic link.

Could you maybe add:

alias ln='ln -s'

to your .bashrc? A quick test of this in my terminal and the alias takes precedent over the ln command. Although, I guess it'd be worth doing a few tests to make certain!

Re: I always forget the argument order of the `ln -s` command

#54
post #2

I used to have this problem. Then I realized that if I want to really copy a file, I type $cp file_from file_to and that $ln -s link_from link_to has a very similar effect to the cp command above. I haven't messed this up ever since.

In my experience the more variable argument often comes last, presumably for easy reuse. For example...

  $chown user1 file1
  $chown user1 file2

  $ln -s file1 file2
  $ln -s file1 file3
...seems more likely than...

  $chown user1 file1
  $chown user2 file1

  $ln -s file1 file2
  $ln -s file3 file2

Re: I always forget the argument order of the `ln -s` command

#57
post #2

I used to have this problem. Then I realized that if I want to really copy a file, I type $cp file_from file_to and that $ln -s link_from link_to has a very similar effect to the cp command above. I haven't messed this up ever since.

This happens to be the first comment in the thread on Reddit.

Re: I always forget the argument order of the `ln -s` command

#58
post #41

Earlier quoted context omitted.

This is a crime against usability IMO. Another comment mentioned that tar takes arguments as "target source" rather than "source target". Ever notice that for everything in the world that screws, like valves or screws or bottle caps, counter-clockwise loosens and clockwise tightens? How is it we got the whole world to agree on that convention, but software is 50/50 on how we order the source and destination?

tar is like that because of command lines tar [args] [one thing] [list of things] it'd be wierd if it was tar [args] [list of things] [filename] ... but i will admit i frequently make that mistake.

tar is actually

  tar [args] [list of things]
where [args] may contain [-f filename], among other things.

That is, the destination filename is an optional argument; by default tar outputs to a tape device or stdout, depending on the implementation.

At least in GNU tar, the target filename can very well be specified as the last argument:

  tar -c foo.txt bar.txt baz.txt -f stuff.tar

Re: I always forget the argument order of the `ln -s` command

#59
when I noticed that I was messing up when using ln, I started thinking this way: "write what you already know first, so you have time to think about what you'll write next

"what you already know" being the existing file and the second part being the name of the link to the existing file.

I never got it wrong again.

Post reply on HN