Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

While setting classpaths in the .bashrc, I was wondering if there was a way to copy the current output from the shell for pasting later into some editor. What I am trying to accomplish is as follows:

  1. Get the current file path using pwd, e.g. - /SomeFolder/java/bin
  2. Use "some" command to copy the output of pwd into the buffer instead of selecting it using the mouse and copying it.
  3. Pasting the path(/SomeFolder/java/bin) in the .bashrc.

I was thinking if there was a way to do it in a mouse free manner.

share|improve this question
up vote 2 down vote accepted
pwd | xsel -b

pwd | xclip -selection clipboard
share|improve this answer
Perfect! This is exactly what I needed. – sc_ray Sep 27 '11 at 15:26
On Mac OSX, pbcopy and pbpaste would accomplish the same trick. – sc_ray Sep 27 '11 at 15:32

Way too easy:

pwd >> ~/.bashrc
share|improve this answer

This is usually by redirecting output of a command. pwd >> .bashrc (note the double >) redirects the output of pwd and adds it to .bashrc instead of to your screen.

You probably want: echo "export CLASSPATH=$CLASSPATH:$(pwd)" >> ~/.bashrc

share|improve this answer
He probably wants that, but he has to learn to ask his questions the right way ;) – m0skit0 Sep 27 '11 at 15:10
Great! This would work but is there a way to have the output of the command buffered so that I can yank it to anywhere, .bashrc or just an empty text file? – sc_ray Sep 27 '11 at 15:12
Still pwd >> anywhere_you_want. Or I didn't understand your question. – m0skit0 Sep 27 '11 at 17:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.