/r/commandline
This is for anything regarding the command line, in any operating system. All questions (including dumb ones), tips, and links to interesting programs/console applications you've found or made yourself are welcome. Linux / BSD / OSX / Windows CLI and TUI apps or questions or comments, we're happy to take them all!
-----------------------------
/ This is for anything
| regarding the command line, |
| in any operating system. All |
| questions (including dumb |
| ones), tips, and interesting |
| programs/console applications |
| you've found or made yourself |
| are welcome. Please read the |
| rules, and you're welcome to |
| flair your posts if you want |
\ to. / |
---|
\ ^__^
\ (OO)\_______
(__)\ )\/\
||----w |
|| ||
commandline@reddit ~ $ _
If you're asking for help, remember to help the community by stating what OS and version you're using, and if at all possible paste any commands you've tried and any errors or output that you've seen.
Related subreddits:
/r/commandline
Hi everyone!
I am Sanzhar, a Computer Science Freshman who is trying to build some fun staff. Yesterday I created and published a npm wrapper that console logs "Skill issues" banner when error occurs. Could you please check this out and leave recommendations or any other thoughts about this little fun project? Can you please recommend any other ideas I have to try to build over this summer?
Install by typing: npm install -g skill-issues
Execute any npm command with Skill Issues, by replacing npm
with sis
or skill-
issues
command.
Links for more information:
https://www.npmjs.com/package/skill-issues
https://github.com/sanxzhar/skill-issues
To dynamically construct an FFmpeg command to utilize only the desired devices, you can follow these general steps:
List available devices: Use a command-line tool or library to list available audio and video devices. For example, on Linux, you can use arecord -l
for audio devices and v4l2-ctl --list-devices
for video devices.
Parse device information: Write a script or program to parse the output of the device listing commands and extract relevant information such as device IDs, names, and capabilities.
Filter out unused devices: Implement logic to filter out unused devices based on criteria such as device type (audio or video), device capabilities, or user preferences.
Construct FFmpeg command: Based on the filtered device information, dynamically generate the FFmpeg command with the appropriate input options for the selected devices.
Here's a simplified example in Python:
import subprocess
# Function to list audio devices
def list_audio_devices():
return subprocess.check_output(['arecord', '-l']).decode('utf-8')
# Function to list video devices
def list_video_devices():
return subprocess.check_output(['v4l2-ctl', '--list-devices']).decode('utf-8')
# Parse device information and filter unused devices
def filter_devices(device_list):
# Implement your filtering logic here
# For simplicity, let's assume all devices are used
return device_list
# Construct FFmpeg command
def construct_ffmpeg_command(audio_devices, video_devices):
# Replace this with your actual FFmpeg command construction logic
ffmpeg_command = f'ffmpeg -f alsa -i {audio_devices} -f v4l2 -i {video_devices} output.mp4'
return ffmpeg_command
# Main function
def main():
audio_devices = list_audio_devices()
video_devices = list_video_devices()
# Filter out unused devices
filtered_audio_devices = filter_devices(audio_devices)
filtered_video_devices = filter_devices(video_devices)
# Construct FFmpeg command
ffmpeg_cmd = construct_ffmpeg_command(filtered_audio_devices, filtered_video_devices)
print("Generated FFmpeg command:", ffmpeg_cmd)
if __name__ == "__main__":
main()
This script provides a basic framework for dynamically constructing an FFmpeg command based on available audio and video devices. You'll need to replace the placeholder logic with actual parsing and filtering code tailored to your specific requirements and environment.
Hello. I have a noob question related to running Linux script on different shells. I have written a bash script and in the first I have provided #! /bin/bash
for script to be execute using Bash.
But what if someone has some different shell and does not have Bash ? Does the user need to change manually bash
into something else ? Is there some way to make the script compatible with multiple different Linux shells ? And is it possible for user not having Bash to run bash script using some other shell ?
**UPDATE**: Problem solved. Limited the use of elevated privileges by only using sudo in the clamscan command and running the script as normal user. Now works perfectly.
I have a bash script that creates a temp file with filenames, it then feeds that list to clamscan for scanning only files that have been modified. I'd like to open the log file with the application "kate" at the end of the script and then exit the existing terminal. It isn't working. The script runs the scan, but then just exits without opening the logfile. The command itself is accurate and works brilliantly if run What am I doing wrong?
#!/usr/bin/bash
# CLAMSCAN RECENTLY CHANGED FILES
# DIRECTORIES TO SCAN
scan_dir="/home/"
# TEMPORARY FILE
list_file=$(mktemp -t clamscan.XXXXXX) || exit 1
# LOCATION OF LOG FILE
log_file="/home/clamweekly.log"
# MAKE LIST OF NEW FILES
if [ -f "$log_file" ]
then
# use newer files then logfile
find "$scan_dir" -type f -cnewer "$log_file" -fprint "$list_file"
else
# scan modified in last 7 days
find "$scan_dir" -type f -ctime -7 -fprint "$list_file"
fi
if [ -s "$list_file" ]
then
# Scan files
clamscan -i -f "$list_file" > "$log_file"
else
# remove the empty file, contains no info
rm -f "$list_file"
fi
# OPEN THE LOG FILE TO REVIEW AND CLOSE THE TERMINAL
kate $log_file & disown
exit
Hey fellow CLI nerds :)
cwf
or Copy with Friends is a small CLI tool for a collaborative clipboard. You can send and receive content from and to your friends or colleagues.
https://reddit.com/link/1cpvegr/video/hxwkep374wzc1/player
Feel free to check cwf
out on Github.
What's new in 6.0?
In a nutshell, ugrep
See ugrep.com for the installation and user guides and the ugrep GitHub project repo
Basically, I wanted to install fastfetch on a windows 11 desktop but i'm not sure how to do it. Can someone just give me a quick rundown on how to?
I use vim and occasionally neovim.
Is there a function like Register for bash?
I want to copy something specific in a global register and then have it available in another environment.
I'm taking a Bash tutorial and I'm supposed to figure this out, but don't know what to look for:
ls -d f* q* | tee ls.txt
ls -d f* q* 2>&1 | tee ls.txt
find . -type f | wc -l
The man page doesn't explain things clearly for a beginner, and some stuff I don't find. I haven't even found "-type" on Google.
I'm not asking for the answers, but I would like to be pointed into the right direction. It can be a typed tutorial or video.
Also are there resources that explains the man pages?
I set Emacs as my external editor for MC. I run Emacs from my terminal using emacs -nw. I set up an alias in my .bashrc alias mc='EDITOR=emacsclient -nw mc... and it works. I open MC in another terminal, F4 opens the selected file in my already opened Emacs instance. But untill I close the file in Emacs the MC window says waiting... and this is not what I want. Basically I'd like to send a file to Emacs and keep browsing other files in MC maybe send another file etc.
tia
Does anyone know if it's possible natively to send a command to a specific firefox tab like pause/play any running media?
I would like to setup a keyboard shortcut to pause/resume any tabs that have plex/youtube playing. Even if there's no direct support for pausing, if I could just send a JS snippet to a specific tab I could figure out how to interact with whatever media is in that tab.
First of all, I am sadly a Windows user. I have to use a Windows PC for my job. With that being said, I have managed to install Zsh, NuShell, and PowerShell 7.
My problem is that I don't really know how to truly maximize these tools. I mostly need something to automate tasks like text manipulation, folder and file creation, searching for text, etc.
I used to use Python, but I find it to be overkill for the tasks I need, when I need something very powerful and complex I use it. But if its something like moving x files to y folder I think shell commands do that more efficiently.
I already know the basic commands and can navigate easily any shell. What I need is that specific scripting knowledge for automation. Any suggestions would be greatly appreciated.
I have been working on Migrating AWS Lambda functions from the Go1.x runtime to the custom runtime on Amazon Linux 2, Created the sprint script to list lambda func in all region
https://github.com/muhammedabdelkader/Micro-Sprint/blob/main/reports/list_lambda.sh
Don't forgot the filter command
Hey o/
I kinda got tired of copy pasting my personal "README" to setup my local machine for development, so I decided to automate the process with a multi-thread approach.
Now it takes less than 2 minutes to have my setup ready to go.
Repo: https://github.com/brenoprata10/easy-config
https://reddit.com/link/1clheak/video/avv24ew5rsyc1/player
I've searched around and could only find $^
for referencing the first argument passed to the previous command, analog to the !$
for the last arg. But sometimes I'd like to use the command itself for example after running the command:
> some_really_long_program 'arg1' 'arg2'
, and then I want to search the man page of the command some_really_long_program
.
Without c-p
and deleting all the arguments, is there also a shorthand for this case in bash
for zsh
?
What is Zoxide
Zoxide is a better ‘cd’ with additional features to help you shortcut some repetitive, tedious tasks.
The command ‘cd’ stands for change directory, which is pretty self-explanatory. Let’s say that you have the current file structure, and the current root folder name, in this case, is called `tutorial`. Now, if we want to navigate to the ‘folder1’ directory, we use the following command.
Then, our terminal will be pointed to `folder1` under `tutorial.` If we wish to go up a folder back to `tutorial,` we run the following command.
The `..` will reference the parent directory. There may be instances where you have to navigate to a folder that is 5 layers deep, and once you get there, you will notice that navigating back to the root folder is not as straightforward. You will have to make a mental note of how many folders deep you are and run something like this.
The command above will point your machine 4 folders up. You can start to see the problem. A similar annoyance arises when you initially want to navigate to your project from a new terminal window. Most of my projects are in a folder called ‘code,’ so every time I want to navigate to a project, I run something like the one below.
Where Zoxide comes in
Doing all these navigation jumps becomes a little repetitive after a while. Wouldn’t it be nice if I could just go straight to the project? Well, that’s what Zoxide is for. Zoxide uses ‘z’ instead of ‘cd’. So instead of typing `cd ./code/supercoolproject` every time, you only have to do it once with ‘z’!
Zoxide will remember where you went! It never gets old, and I use it every time. If the end folder has a similar name to another path you z’d to, it will prompt you to pick!
No. Some of you may be saying, “This doesn’t save that much time, “and I will say, yeah, you are right. For me, it is not about the time saved but the convenience it brings. I rather type less than I need to do the same thing.
https://ryanspears.substack.com/p/you-should-probably-start-using-zoxide
https://github.com/ddddddO/packemon
Hi! I have created a TUI tool that allows me to create and send packets of any network layer! Also, it can monitor packets. This tool is still under development.
Hello, i found this thing "aria2c" using 70gb of my internet, how do i install it? im running windows
I'm using eza as a replacement for ls.
I'm looking for a way to set custom colors for some file types (like .odt -> blue, .ods -> green) but I can't find anything helpful.
Is there any way to do it?
Ty!