LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-17-2019, 05:34 AM   #121
Arch59
LQ Newbie
 
Registered: May 2019
Location: The Netherlands
Distribution: Xfce running on Arch-Linux
Posts: 3

Rep: Reputation: Disabled
Smile Return Information About Installed Packages


Return Information About Installed Packages

If you want to know the name, description and all other manner of details about a package use the following command:

Code:
pacman -Q -i packagename
 
Old 06-17-2019, 11:49 AM   #122
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Rep: Reputation: 24
Quote:
Originally Posted by typewar View Post
The shortest command I know:

Code:
> filename
It simply clears a file
I also often use '>' to leave notes in dirs referring to particular files, so I can read them directly in mc (or other file manager), e.g.
Code:
>'Bitter mplayer does not play this properly'
and mc lists the contents of the directory so
Quote:
| Bitter mplayer does not play this properly │ 0│Jun 17 09:43│
│*Bitter.Lake.2015.WEBRiP.x264.mkv │ 2344M│Feb 1 09:20│
 
Old 06-21-2019, 01:33 PM   #123
UCotter
LQ Newbie
 
Registered: Mar 2012
Posts: 4

Rep: Reputation: Disabled
sudo !!
 
Old 06-22-2019, 01:04 PM   #124
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Rep: Reputation: 24
Nesting expansions, substitutions etc in Bash

While bash is somewhat limited in this respect, I find the following very useful to randomly or specifically select a single file from many:
Code:
mapfile -t <<< "$(ls *.mp3)" f
play ${1:-${f[$((RANDOM%${#f[@]}))]}}
 
Old 06-24-2019, 02:28 PM   #125
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Install httpie and add a shell command (alias/function/script) called "dl" that just calls "http --download" with any provided arguments.

Then you can do:

Code:
dl https://url/to/file.tar.bz2
Much better than either wget or cURL.

Last edited by dugan; 06-24-2019 at 06:09 PM.
 
2 members found this post helpful.
Old 06-24-2019, 02:38 PM   #126
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,711

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Question

Quote:
Originally Posted by dugan View Post
Install httpie and add a shell command (alias/function/script) called "dl" that just calls "httpie --download" with any provided arguments.

Then you can do:

Code:
dl https://url/to/file.tar.bz2
Much better than either wget or cURL.
Hi dugan. How is it better?
 
Old 06-24-2019, 02:40 PM   #127
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by linustalman View Post
Hi dugan. How is it better?
For one thing, it handles redirection properly by default. No need to add the "--content-disposition" flag that you'd need for wget.

The progress meter also looks much more cool.
 
1 members found this post helpful.
Old 06-24-2019, 02:41 PM   #128
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,711

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Thumbs up

Quote:
Originally Posted by dugan View Post
For one thing, it handles redirection properly by default. No need to add the "--content-disposition" flag that you'd need for wget.

The progress meter also looks much more cool.
I see, thanks.
 
Old 07-13-2019, 07:19 PM   #129
hamx99
LQ Newbie
 
Registered: Jul 2019
Posts: 5

Rep: Reputation: 0
edit

Last edited by hamx99; 07-13-2019 at 11:54 PM.
 
Old 07-14-2019, 08:51 AM   #130
djk44883
Member
 
Registered: Aug 2008
Location: Ohio
Distribution: debian
Posts: 141

Rep: Reputation: 29
Quote:
Originally Posted by dugan View Post
Install httpie

Thanks, I find it useful with it's ability to parse JSON


I'm aware Firefox does this beautifully, but you know, the command line is your friend.
 
Old 07-15-2019, 01:35 AM   #131
Leida
LQ Newbie
 
Registered: Jun 2019
Posts: 10

Rep: Reputation: Disabled
Quote:
Originally Posted by dugan View Post
For one thing, it handles redirection properly by default. No need to add the "--content-disposition" flag that you'd need for wget.

The progress meter also looks much more cool.
Yeah,you are right,it is always been cool.
 
Old 07-19-2019, 07:55 AM   #132
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Rep: Reputation: 13
Code:
watch
cause I'm lazy
and
Code:
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]+[ ]*//" ) [$RETRN_VAL]"'
to see what people are typing on my servers
 
Old 07-19-2019, 08:58 PM   #133
mike9b
LQ Newbie
 
Registered: Apr 2008
Distribution: Ubuntu 22.10
Posts: 6

Rep: Reputation: 3
Code:
cal -3
for a calendar.

Last edited by mike9b; 07-19-2019 at 09:00 PM.
 
3 members found this post helpful.
Old 07-20-2019, 04:22 AM   #134
rhamel
Member
 
Registered: Sep 2009
Location: Caribbean
Distribution: Slackware 15.0, Proxmox 7.4-17, FreeBSD 13.2
Posts: 70

Rep: Reputation: Disabled
How would you set this up?

KatrinAlec


Code:
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]+[ ]*//" ) [$RETRN_VAL]"'
to see what people are typing on my servers


This is interesting.
How would you set this up so that a user would not be aware that the commands were being logged?


Thanks.
 
Old 08-10-2019, 11:32 PM   #135
NachoLord
Member
 
Registered: Jul 2018
Location: Somewhere between here and there.
Distribution: Ubuntu, Debian, Arch
Posts: 47

Rep: Reputation: Disabled
Here's a a way to listen to music randomly:

Code:
(SHUF='shuf'$'\n''--random-data=/dev/urandom'; IFS=$'\n'; exec mpv $(find -L ~/Music -type f | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | grep -iE 'mp3$|m4a$|ogg$|flac$|wav$|wma$|opus$|oga$'))
This will cause mpv - or theoretically any other player - to play any regular files (or symbolic links that point to regular files) with certain extensions. (Namely, those passed as arguments to grep. More could be added if desired.) I like to put make a SHUF command, and save it as a script, so that I can call it whenever I need it, but since I'm too lazy to post said script here, I made a simplified version as a shell variable.

Here's another method that requires mpv (it might also work with mplayer, but since I don't use mplayer, I'm not incentivized to test it):

Code:
SHUF='shuf --random-data=/dev/urandom'; find -L ~/Music -type f | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | grep -i mp3\$ | mpv --playlist=-
This makes a randomly-generated list of files, and passes it to mpv via stdin. From there, mpv won't recognize this list without the --playlist=- argument. If you use relative paths, mpv will resolve those paths relative to the current working directory.

Here's a similar way to randomize your mp3s:

Code:
mpv --playlist=<(SHUF='shuf --random-data=/dev/urandom'; find -L Music -type f | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | grep -i mp3\$)
Unlike the above, mpv will resolve any relative paths from /dev/fd. So, if you're in your HOME directory, you'll probably get bunch of error that say something like this: "[file] Cannot open file /dev/fd/Music/(blablabla)/file.mp3: no such file or directory" before mpv exits. Thus, it's probably better to use command substitutions (such as $(command)) than process substitutions (such as <(command)) in this case.

Here's yet another way to do this:

Code:
SHUF='shuf --random-data=/dev/urandom'; find -L ~/Music -type f | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | $SHUF | xargs -0 -d \\n -s 1234567890 mpv
Do note that xargs will print a message to stderr saying like "value 1234567890 for -s option should be <= 2092657". I've seen that latter number change from one instance to another, and thus I don't even bother to memorize it. Honestly, this error can be safely ignored, and mpv (or any other player) should start playing regardless. This is probably the least graceful way of doing this, but it works well enough.

I also like resetting both my terminal and my shell by typing:

Code:
printf \\ec && exec bash
I love one-liners.

Happy Hacking!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: What is your favorite Linux terminal trick? LXer Syndicated Linux News 0 08-01-2018 12:41 PM
Poll: (Without the poll) - How is Linux used in your workplace? SlowCoder General 13 09-11-2007 11:03 PM
vim :gui trick and undo-trick dazdaz Linux - Software 3 09-10-2007 02:45 PM
Poll: What is your favorite brand of Motherboard? dstrbd1 Linux - Hardware 2 02-16-2006 05:40 PM
Weekly Hardware Poll, Dec 14th: What's your favorite notebook? finegan Linux - Hardware 18 12-03-2004 12:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:29 PM.

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