After running the following command...

# locate -i "little"

I receive these results.

/mnt/external/Songs/The White Stripes/[1999] The White Stripes/14 little people.mp3
/mnt/external/Songs/The White Stripes/[2000] De Stijl/03 Little Bird.mp3
/mnt/external/Songs/The White Stripes/[2001] White Blood Cells/06 - little room.mp3
/mnt/external/Songs/The White Stripes/[2003] Elephant/the white stripes - elephant - 10 - little acorns.mp3
/mnt/external/Songs/The White Stripes/[2005] Get Behind Me Satan/11 Little Ghost.mp3
/mnt/external/Songs/The White Stripes/[2007] Icky Thump/Little Cream Soda.mp3

How do I pipe one of the results of the locate command to another command. Essentially I'll be prepending "totem" (media player) to the location of file and then I'll execute the command to play one of the songs.

EDIT: I just realized I can't copy and paste with the mouse because a lot of the albums; I have the years encased in parathensis (ex. Elephant (2003)) which have to be manually escaped...

2nd EDIT: Roland, I am running locate to find the path of the song so I can play the song using totem media player.

# totem /mnt/external/Songs/The White Stripes/[2007] Icky Thump/Little Cream Soda.mp3

Essentially I would like to know how to copy the path of a song location returned by the locate command, and then paste that location into the terminal so I can give totem a location of the song.

  • 1
    Sorry, what do you want to copy and where to? It is not really clear for me. Give more details about using the output of the locate! – antivirtel Sep 14 '11 at 10:38
  • i think the OP wants to know how to pipe a single result from the output to totem so as to play a single file. – Nitin Venkatesh Sep 14 '11 at 10:48
  • Thanks for the clarification nitstorm. Is there any way I can choose which one of the results to play in the case of there being many songs located? – user784637 Sep 14 '11 at 10:50
  • If I understand you correctly, you can use select with cursor, then Ctrl + Shift + C, and paste back to terminal Ctrl + Shift + P, after the totem command. (Use double quotes if required.) – antivirtel Sep 14 '11 at 10:53
  • That didn't work. When I hit Ctrl+Shift+C it starts to populate my last search queries into command line. Also I can't use a cursor (I assume that cursor is synonymous with mouse), read my 1st edit. A lot of my songs paths include directories that have paretheses, so I would have to manually escape those characters. – user784637 Sep 14 '11 at 10:59

If you are able to restrict your output to a single line, perhaps with help from grep, you can use the following syntax:

totem "$(locate -i "hardest button" | grep pattern)"

Otherwise, you can use screen that allow to select a portion of the buffer to paste into another location.

Probably also using the mouse from the keyboard (see keyboard preferences) can be of help.

Finally, I don't think gnome-terminal allow to select something without the mouse, there is no shortcut for this.

  • 1
    gnome-terminal will allow you to select with double or triple clicks, and paste with the (real or emulated) middle mouse-button. – belacqua Sep 14 '11 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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