/r/shell
News, articles, tips and tools covering shell scripting and command-line interfaces of all flavors.
News, articles, tips and tools covering shell scripting and command-line interfaces of all flavors.
Resources:
Other subreddits you may like:
Does this sidebar need an addition or correction? Tell me here
/r/shell
Hello everyone!
I want to introduce my current project crazy-complete.
It is a tool that generates shell auto-completion files using a single configuration file.
Key Features
Other Features
If you're tired of maintaining completion scripts for different shells, crazy-complete may be for you.
Even if you decide against using generated scripts, the output of the tool may serve as an inspiration.
Let me know what you think. If you need support or have any questions or improvement-ideas, don't hesitate to ask!
And if you like the tool, please give it a star on GitHub
I dont understand why i cant change certain file permitions (i can change some but not all).
I tried running sudo but it cant find the command and i cant seem to instal sudo with "su -".
Im running "git bash" on a windows... I also have 2 users, one personal, one for coding. Might it be the user settings? If so what and how do I change it... No one in my cluster has any info, help 💀🙏
Hi, I'm just curious: what does this mean?
I know it's telling the machine to use bash, but like, why is it a "#!" for example? How/why was it decided that way?
On a road trip to Dallas, TX, we stopped at a Shell (the gas station) in Arkansas to hot to the bathroom. There was fucking BARNACLES on the SINK. BARNACLES! My hands felt dirtier after washing. Words cannot describe how infuriated I was, and still am, despite the encounter being a week ago. I needed to vent about this. This is not clickbait. This is REAL. Never going to a shell again.
Hi, new to coding just started studying shell.
Cant seem to change this files permitions, what am i doing wrong?
(i need to give g and o x permition, have already tried numeric and symbolic methods)
I need to know everything the pc is doing, for example I need to read it and be able to copy and paste the text to activate it, for example the if any app is open and anything I do on it I can see and still copy and paste to do the same, yes I know it's very weird, but if you smart guys or girls know I would love to know, sorry I didn't explain it well
shell script-1 :
#!/bin/bash
cd /(path)/DB/test
for line in $(cat ./test_list.txt); do
./../batch_download.sh -f ./${line} -p &
done
I closed the terminal, but the execution didn't stop. I checked, it is truly downloading files.
However,
shell script-2:
#!/bin/bash
cd /(path)/DB/test
./../batch_download.sh -f ./entry0.txt -p
I cannot close the terminal.
Hi All
I have implemented a unit test for a Shell using shellspec. And I am always thrown the above error in 'before all' and 'after all' both. Even though the log contains exit code 0 which basically indicating there is no error none of my tests are executing.
I have added extra logs and also redirected the errors but still I am facing this error and am out of options. I am using the latest version of Shellspec as well.
I am mocking git commands in my test script. But it is quite necessary for my tests as well.
I even checked for the relevent OS type in the setup method
# Determine OS type
OS_TYPE=$(uname 2>/dev/null || echo "Unknown")
case "$OS_TYPE" in
Darwin|Linux)
TMP_DIR="/tmp"
;;
CYGWIN*|MINGW*|MSYS*)
if command -v cygpath >/dev/null 2>&1; then
TMP_DIR="$(cygpath -m "${TEMP:-/tmp}")"
else
echo "Error: cygpath not found" >&2
exit 1
fi
;;
*)
echo "Error: Unsupported OS: $OS_TYPE" >&2
exit 1
;;
esac
Any guidance is immensely appreciated.
I recently published a comment about my todo list on HN and a few people asked about it. I decided to do a quick write-up of the simple commands I put together to accomplish this in the shell (zsh in my case but it likely works in bash too).
Asking for a brother who is building tools to help other shell/Terminal layer programmers. Thank you.
No, something different than you think... xz performs up to 2% better on ARM64 than AMD64 with the same settings and I have double checked the version, it is the same! gzip on the other hand... no change at all. Also interesting, xz -1 and AMD64 is WAY faster and better than gzip except memory usage but even 100MByte are pretty tame nowadays. So basically gzip is now superfluous in ever aspect, even on my 1990 Amiga with bash and xz I can unpack those Archives, and faster than xz too. And no, I didn't benchmark the Amiga too. I only remember it from the last time I booted it up.
amd64:
578339776 test
40926066 test.gz1
40024392 test.gz2
39818807 test.gz3
36787548 test.gz4
35988603 test.gz5
35188701 test.gz6
35100687 test.gz7
32072861 test.gz8
31762517 test.gz9
23958376 test.xz1
22207696 test.xz2
21483232 test.xz3
25643828 test.xz4
24781276 test.xz5
24459080 test.xz6
24041684 test.xz7
23434612 test.xz8
22865948 test.xz9
15539300 test.xz9e
arm64: 578339776 test
40926066 test.gz1
40024392 test.gz2
39818807 test.gz3
36787548 test.gz4
35988603 test.gz5
35188701 test.gz6
35100687 test.gz7
32072861 test.gz8
31762517 test.gz9
23515536 test.xz1
21855000 test.xz2
21210096 test.xz3
25397736 test.xz4
24562780 test.xz5
24230096 test.xz6
23841668 test.xz7
23250764 test.xz8
22824292 test.xz9
If you are interested in the rest, the first comma column is i7-6700k, the second comma column is Pi400:
578339776 test
for I in 1 2 3 4 5 6 7 8 9 9e; do for A in 1 2 3; do echo "RUNNING $I - $A"; ( time ( xz -$I <test >test.xz$I ) ) 2>&1 | grep real; done; done
xz -1 1,9 35,9 23958376 test.xz1
xz -2 2,8 49,6 22207696 test.xz2
xz -3 4,4 73,1 21483232 test.xz3
xz -4 5,0 88,9 25643828 test.xz4
xz -5 8,1 143,0 24781276 test.xz5
xz -6 13,2 246,2 24459080 test.xz6
xz -7 15,0 24041684 test.xz7
xz -8 21,5 23434612 test.xz8
xz -9 32,9 22865948 test.xz9
xz -9e 155,4 15539300 test.xz9e
for I in 1 2 3 4 5 6 7 8 9 9e; do for A in a b c; do echo "RUNNING $I$A"; ( time ( gzip -$I <test >test.gz$I ) ) 2>&1 | grep real; done; done
gzip -1 2,8 8,4 40926066 test.gz1
gzip -2 2,9 8,5 40024392 test.gz2
gzip -3 3,0 8,4 39818807 test.gz3
gzip -4 3,7 10,7 36787548 test.gz4
gzip -5 3,8 11,2 35988603 test.gz5
gzip -6 4,6 14,5 35188701 test.gz6
gzip -7 5,2 16,8 35100687 test.gz7
gzip -8 7,8 27,2 32072861 test.gz8
gzip -9 9,2 34,0 31762517 test.gz9
I think that is self-explanatory.
Hello, I am new to scripting and trying to make a script that will make it easier to use yuescript to code with the love2d framework. I am currently facing an issue with the zip command.
yue -t lua src
rm game.love
zip -r game.love lua
love game.love
The probem is that the root is lua directory and not main.lua, using lua/* doesn't seem to work, the rest works as intended
Here is how to customize your boring default terminal to boost your productivity. Discover useful terminal commands for navigation and shortcuts to enhance your terminal experience.
etcsh is an enhanced version of the original tcsh, which is a version of the original Berkeley C shell implementing file name completion and command line editing.
etcsh features the following enhancements and fixes over the original tcsh.
• Function declarations;
• variable assignment from pipes and redirections;
• comments on interactive sessions;
• tell whether stdin
is empty or not;
• variable expansion on expressions corrected;
• piped built-ins are forked;
• missing test
built-in implemented;
• read-write variable flag;
• exit
shall cancel lists.
More is to come. Feedbacks and contributions are much appreciated.
I have written a shell that uses the Python language as the scripting language: it's a shell environment that combines the expressiveness of shell pipelines with the power of python iterators.
It can be used in two major ways:
Obligatory example:
140:/home/redhog/Projects/beta/pieshell >>> for x in ls(-a):
... if x.endswith('.py'):
... print x
...
setup.py
Hi all,
after using fish for about 5 years, I have tried the rc shell. I would like to share my experience so far: rc shell instead of bash or fish. If there are any other rc users in this sub, maybe you can help me with some of the open points (like how to copy the current command buffer or better integration of fzf).
VAR1=123 VAR2=456 VAR3=789
VARIABLES="VAR1 VAR2 VAR3"
for i in $VARIABLES do echo "$i = $$i #something like this
done
Expected output: VAR1 = 123
Hi
I'm sure some of you have ever wished to be able to just easily sync changes from one windows terminal instance to another one, for example a secondary laptop or a work device.
If so, consider adding a thumbs-up or your comment to this feature request, thanks!
hello
https://github.com/MonkeyWearingAFezWithAMop/UnityBuild-Upload/blob/main/install_butler.sh
I was trying to work out how to install butler for itch.io
https://itch.io/docs/butler/installing.html
but got stuck trying to "add butler to path" (whatever that means)
I asked chatgpt to write a script to do this and it made this and it seemed to work...
can anyone explain what "adding to path" means?
and what exactly was I supposed to do once I got to this step in the instructions
I was using a macbook pro if that makes any difference to you explanation?
thanks
I am trying to process multiple files present in a folder. My requirement is to process ALL the files but at max 15 in parallel. I wrote the below script to achieve the same.
However, this isn't working as expected. This script is processing all the files in the firs iteration (i.e. 15 in this case) but once the first 15 are done, it's processing alternate files. Thus if a folder has say 27 files, it's processing all the first 15 and then 6 of the remaining 12.
What am I doing wrong and how can I correct it?
#!/bin/bash
# Path to the folder containing the files
INPUT_FILES_FOLDER="/mnt/data/INPUT"
OUTPUT_FILES_FOLDER="/mnt/data/OUTPUT"
# Path to the Docker image
DOCKER_IMAGE="your_docker_image"
# Number of parallel instances of Docker to run
MAX_PARALLEL=15
# Counter for the number of parallel instances
CURRENT_PARALLEL=0
# Function to process files
process_files() {
for file in "$INPUT_FILES_FOLDER"/*; do
input_file=`basename $file`
output_file="PROCESSED_${input_file}"
input_folder_file="/data/INPUT/${input_file}"
output_folder_file="/data/OUTPUT/${output_file}"
echo "Input File: $input_file"
echo "Output File: $output_file"
echo "Input Folder + File: $input_folder_file"
echo "Output Folder + File: $output_folder_file"
# Check if the current number of parallel instances is less than the maximum allowed
if [ "$CURRENT_PARALLEL" -lt "$MAX_PARALLEL" ]; then
# Increment the counter for the number of parallel instances
((CURRENT_PARALLEL++))
# Run Docker container in the background, passing the file as input
# docker run hello-world
docker run --rm -v /mnt/data/:/data my-docker-image:v5.1.0 -i $input_folder_file -o $output_folder_file &
# Print a message indicating the file is being processed
# echo "Processing $file"
else
# If the maximum number of parallel instances is reached, wait for one to finish
wait -n && ((CURRENT_PARALLEL--))
fi
done
# Wait for all remaining Docker instances to finish
wait
}
# Call the function to process files
process_files