LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-30-2008, 07:28 PM   #1
ifeatu
Member
 
Registered: Sep 2008
Distribution: Fedora 9
Posts: 68

Rep: Reputation: 15
Shell Command list


Where is the .sh_history file in ubuntu...I want to have access to all of the commands that I have typed...
 
Old 10-30-2008, 07:35 PM   #2
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 5, Linux Lite
Posts: 4,312

Rep: Reputation: 210Reputation: 210Reputation: 210
Try looking for a .bash_history file in your home directory.
 
Old 10-30-2008, 08:16 PM   #3
ifeatu
Member
 
Registered: Sep 2008
Distribution: Fedora 9
Posts: 68

Original Poster
Rep: Reputation: 15
Nice!

Nice! That worked...another question...how do I port the results of the "locate" command into another command (for scripting purposes) like say...vi. I keep trying:

locate <file> | vi
or
vi | locate <file>
or
locate file > vi


Can you lead me in the right direction?
 
Old 10-30-2008, 08:30 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
You probably want

Code:
vi $(locate file)
# or
vi `locate file`
Note that these are backticks, and not regular single quotation marks.
 
Old 10-30-2008, 08:32 PM   #5
ifeatu
Member
 
Registered: Sep 2008
Distribution: Fedora 9
Posts: 68

Original Poster
Rep: Reputation: 15
Multiple results

Quote:
Originally Posted by i92guboj View Post
You probably want

Code:
vi $(locate file)
# or
vi `locate file`
Note that these are backticks, and not regular single quotation marks.
Thats good...but what about if the output has multiple results?
 
Old 10-30-2008, 09:07 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
You'd prob need to output locate to a tmp file and then replace newlines with space eg using sed.
 
Old 10-31-2008, 12:58 AM   #7
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
Quote:
Originally Posted by ifeatu View Post
Thats good...but what about if the output has multiple results?
If there's a problem with the line feeds, you can always parse one at a time:

Code:
locate <filename> | while read file; do vi "$file"; done
or

Code:
for i in `find filename`; do vi "$i"; done
However, this will open the files sequentially (you close vim, and the next one is opened), and not all at the same time. If you need that, then you need further processing as the previous poster noted. But there's no need to use a file

Code:
vi `locate file | tr '\n' ' '`
Should work, if I didn't make any typo

PS. Things will go complicated if you have file names with spaces.

Last edited by i92guboj; 10-31-2008 at 01:01 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 08:19 PM
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 04:38 PM
how to list all users in shell? binary_0011 Linux - Newbie 2 05-02-2006 12:40 PM
Shell Script - filter list eluzi Linux - Software 3 03-17-2006 07:06 PM
Command to run another command against a list of files psweetma Linux - General 3 11-09-2005 06:29 PM

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

All times are GMT -5. The time now is 12:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration