# Copy code from shell

**URL:** <https://community.unix.com/t/copy-code-from-shell/166046>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [October 11, 2006, 11:34pm UTC](https://community.unix.com/t/copy-code-from-shell/166046 "2006-10-11T23:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yohoshua](https://community.unix.com/letter_avatar/yohoshua/32/5_5575768a8748004e209b776fc1b2916d.png) [@yohoshua](https://community.unix.com/u/yohoshua)\
**Post date:** [October 11, 2006, 11:34pm UTC](https://community.unix.com/t/copy-code-from-shell/166046/1 "2006-10-11T23:34:11Z")

</div>

Hi everyone.. I'm a full-fledged newbie so bear with me. =)

I'm running code in the shell, and I'd like to copy the lines into a text file. Everytime I try using Contrl-C, the lines repeat as code. Is there some sort of export history function I can use?

---

<div class="post-metadata">

**Author:** ![Hitori](https://community.unix.com/user_avatar/community.unix.com/hitori/32/394_2.png) [@Hitori](https://community.unix.com/u/Hitori)\
**Post date:** [October 12, 2006, 2:20am UTC](https://community.unix.com/t/copy-code-from-shell/166046/2 "2006-10-12T02:20:09Z")

</div>

1) you can copy history from history file (e.g. if you use bash shell it will be ~/.bash\_history)  
2) if you use xterm (or gnome-terminal, etc.) just select block of text with mouse and it will be stored in the buffer  
3) see bash(1) (or corresponding man for your shell), section 'Killing and Yanking'
