LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-03-2018, 10:28 PM   #1
bk328115
LQ Newbie
 
Registered: Jul 2018
Posts: 22

Rep: Reputation: Disabled
Unhappy In terminal (bash), when you've run commands, and then you press the up arrow and all the commands are there, how to > to a text file.


Ok, so I've got terminal open and running bash. Say I've executed 5 commands. Now they're in the queue and I can scroll through those by using the up and down arrow keys. How can I export that "list" of commands that I've run to a text file. NOT the output of the commands, just the commands themselves. So, if I've run ls, apt-get update, cd /etc, and rm *.txt, for example. If I would export that to a text file, it would look like this:

ls
apt-get update
cd /etc
rm *.txt

I'm running Debian 9 (Stretch) on a 2004 Lenovo Thinkpad x61, with 4GB Ram, and a 1.9 Ghz proc. Using bash shell. Thank you so much for help. I did search for this, but couldn't find exactly what I was looking for.
 
Old 08-03-2018, 10:31 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Code:
history > [somefile.txt]
Thanks for the question. I learned something new because you asked it.
 
2 members found this post helpful.
Old 08-03-2018, 10:37 PM   #3
bk328115
LQ Newbie
 
Registered: Jul 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thanks @frankbell for the quick reply. That's exactly what I was looking for.
 
Old 08-03-2018, 10:44 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
I'm happy I could help. You are most welcome.
 
Old 08-03-2018, 10:57 PM   #5
TheEzekielProject
Member
 
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
There is also a file in your users home directory with your command history. Usually ~/.bash_history
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run commands with pipe from text file? Apostol Linux - General 4 03-11-2018 09:55 AM
bash script to read commands from text file and abort if any command fails hruday Linux - Newbie 10 03-06-2017 05:45 AM
[SOLVED] Bash shell script performs differently to commands run in terminal ocpaul20 Linux - General 4 05-13-2015 08:55 PM
USB Low Level commands (embedded Linux, terminal commands) JonCombat Linux - Newbie 2 01-05-2013 02:34 PM
Run commands found in plain text file splunk Linux - Software 6 02-02-2008 11:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration