Making an alias disregard other aliases
I'm trying to rebind some dangerous commands. I keep accidentally invoking dd in the terminal, so I had the idea of aliasing "dd" to an error message, and another alias like "disk-destroyer" to the actual dd utility into. So I did this:
​
​
The problem here is that "disk-destroyer" will link back to the dd alias. Is there any way around it?
https://redd.it/ysng2m
@r_bash
I'm trying to rebind some dangerous commands. I keep accidentally invoking dd in the terminal, so I had the idea of aliasing "dd" to an error message, and another alias like "disk-destroyer" to the actual dd utility into. So I did this:
​
alias disk-destroyer='dd'alias dd="echo 'Probably the wrong command. Use alias \"disk-destroyer\" for the actual dd command.'"​
The problem here is that "disk-destroyer" will link back to the dd alias. Is there any way around it?
https://redd.it/ysng2m
@r_bash
reddit
Making an alias disregard other aliases
I'm trying to rebind some dangerous commands. I keep accidentally invoking dd in the terminal, so I had the idea of aliasing "dd" to an error...
Why won’t this bash noscript work?
https://redd.it/ysppjw
@r_bash
#! bin/bash # Printing System Variables #Print Bash shell name echo $BASH # Print Bash shell Version echo $BASH_VERSION # Print Home directory name echo $HOME *https://redd.it/ysppjw
@r_bash
reddit
Why won’t this bash noscript work?
`#! bin/bash #` `Printing System Variables #Print Bash shell name` `echo $BASH # Print Bash shell Version` `echo $BASH_VERSION # Print Home...
How can I loop through all files with file extension within a certain set of extensions?
I want to loop through all files ending in `.mp3` or `.mp4`.
I know that I can do
for f in *.{mp3,mp4}; do
However if there happen to be no mp3 files, f will also assume the value `*.mp3` which is unwanted.
​
If I only want to consider one file extension, I know that I can do
for f in *.mp3; do
[ -f "$f" ] || break
But this does not easily apply to more file extensions.
Thank you for your help!
https://redd.it/ysoiea
@r_bash
I want to loop through all files ending in `.mp3` or `.mp4`.
I know that I can do
for f in *.{mp3,mp4}; do
However if there happen to be no mp3 files, f will also assume the value `*.mp3` which is unwanted.
​
If I only want to consider one file extension, I know that I can do
for f in *.mp3; do
[ -f "$f" ] || break
But this does not easily apply to more file extensions.
Thank you for your help!
https://redd.it/ysoiea
@r_bash
reddit
How can I loop through all files with file extension within a...
I want to loop through all files ending in `.mp3` or `.mp4`. I know that I can do for f in *.{mp3,mp4}; do However if there happen to be no...
Cluster; After the job finishes ,How to initiate file transfer? WinSCP
The cluster I am working with sends emails after finishing a job.
How can I monitor email to initiate the file transfer may be it with WinSCP or through a shell noscript?
Actually, I need to have a large number of plots and calculations to be made on the go; how can I do that?
https://redd.it/ysofcb
@r_bash
The cluster I am working with sends emails after finishing a job.
How can I monitor email to initiate the file transfer may be it with WinSCP or through a shell noscript?
Actually, I need to have a large number of plots and calculations to be made on the go; how can I do that?
https://redd.it/ysofcb
@r_bash
reddit
Cluster; After the job finishes ,How to initiate file transfer? WinSCP
The cluster I am working with sends emails after finishing a job. How can I monitor email to initiate the file transfer may be it with WinSCP or...
Curl request
I have a textfile which i would like to send to my telegrambot. The issue iam facing is that the textfile does not get sorted correctly when i post it through the curl request.
But when i run it in terminal it sorts nicely without any issues.
curl -s --data text="$(cat '/files/test.txt')" --data-urlencode "chat_id=@chatid123" 'https://api.telegram.org/botmyapikey/sendMessage'
This below is the format i want. I've read about word splitting but the quotes around the cat command does not seem to make a difference.
eurusd 1621
gbpusd 1539
eurcad 1332
gbpcad 1116
nzdusd 1054
nzdcad 928
audcad 867
eurgbp 324
xauusd 133
euraud -25
audnzd -128
eurnzd -213
gbpaud -484
gbpnzd -753
usdcad -804
eurchf -840
eurjpy -856
btcusd -1186
gbpjpy -1480
cadjpy -1604
xaujpy -2432
usdjpy -3058
Help is appreciated
https://redd.it/yt5sry
@r_bash
I have a textfile which i would like to send to my telegrambot. The issue iam facing is that the textfile does not get sorted correctly when i post it through the curl request.
But when i run it in terminal it sorts nicely without any issues.
curl -s --data text="$(cat '/files/test.txt')" --data-urlencode "chat_id=@chatid123" 'https://api.telegram.org/botmyapikey/sendMessage'
This below is the format i want. I've read about word splitting but the quotes around the cat command does not seem to make a difference.
eurusd 1621
gbpusd 1539
eurcad 1332
gbpcad 1116
nzdusd 1054
nzdcad 928
audcad 867
eurgbp 324
xauusd 133
euraud -25
audnzd -128
eurnzd -213
gbpaud -484
gbpnzd -753
usdcad -804
eurchf -840
eurjpy -856
btcusd -1186
gbpjpy -1480
cadjpy -1604
xaujpy -2432
usdjpy -3058
Help is appreciated
https://redd.it/yt5sry
@r_bash
How to delete empty lines in multiple files?
I tried this but it didn't worked:
sed -i '/^$/d' *.txt
I want to be able to delete empty lines in files in subdirectories as well.
https://redd.it/ythb7w
@r_bash
I tried this but it didn't worked:
sed -i '/^$/d' *.txt
I want to be able to delete empty lines in files in subdirectories as well.
https://redd.it/ythb7w
@r_bash
reddit
How to delete empty lines in multiple files?
I tried this but it didn't worked: sed -i '/^$/d' *.txt I want to be able to delete empty lines in files in subdirectories as well.
A way to run a noscript called XYZ.sh and the output will be in a file called XYX.out
I was asked to write a noscript that a user could run and the output would be easy for them to copy.
Although this is not what the noscript did it is an example where if you run a noscript called "AScript.sh" the user will see the output and have a noscript called "AScript.out" after.
I hope someone finds the idea useful.
https://redd.it/ytm2ud
@r_bash
I was asked to write a noscript that a user could run and the output would be easy for them to copy.
Although this is not what the noscript did it is an example where if you run a noscript called "AScript.sh" the user will see the output and have a noscript called "AScript.out" after.
I hope someone finds the idea useful.
#!/usr/bin/env bash
# Get the noscript name
Me="${0##*/}"
( (
# do a read from the df command
while read -r MountPoint Type; do
# print out a command
echo "${MountPoint} uses filesystem type ${Type}"
sleep 2
# From inside the first loop do something withn the mount point
while read -r FoundFile; do
# Print out a message
echo "I have found your file \"${FoundFile}\" in filesystem \"${MountPoint}\""
done< <(find "${MountPoint}" -xdev -type f -iname "*[a-c].mp4" 2> /dev/null)
# run a df and pass it to read
done< <(df -PTh -txfs -text{3,4} | awk '!/ilesystem/ { print $7 " " $2}')
) 2>&1 ) | tee "${Me/%sh/out}"
https://redd.it/ytm2ud
@r_bash
Bash noscript to rename files excluding names in an array
I currenlty have a noscript where I rename files by removing whitespace and certain names.
prename -v 's/ /_/g' *
prename -v 's/_-_/_/g' *
prename -v 's/_\(Summer-HD\)//ig' *
prename -v 's/_\(Hammer\)//ig' *
prename -v 's/_\(Hardware-Hybrid\)//g' *
prename -v 's/_\(digital\)//ig' *
prename -v 's/_\(Resolution-SD\)//ig' *
What I have tried is a for loop and place name in an array but that has not worked.
exclude=('(Summer-HD)' '(Hammer)' '(digital)' '(Resolution-SD)' '(Vacation)' '(Hammer-Hybrid)')
for x in "${exclude[@]}";
do prename -v 's/$x/_/g' * {} \;
done
This for loop does not work at all, and I'm not sure if I can pass a variable to prename. I would like to put the names in an array since I currently have more than 200 that i would like to remove. This list will grow as I restore these files from old backups.
https://redd.it/ytqnsb
@r_bash
I currenlty have a noscript where I rename files by removing whitespace and certain names.
prename -v 's/ /_/g' *
prename -v 's/_-_/_/g' *
prename -v 's/_\(Summer-HD\)//ig' *
prename -v 's/_\(Hammer\)//ig' *
prename -v 's/_\(Hardware-Hybrid\)//g' *
prename -v 's/_\(digital\)//ig' *
prename -v 's/_\(Resolution-SD\)//ig' *
What I have tried is a for loop and place name in an array but that has not worked.
exclude=('(Summer-HD)' '(Hammer)' '(digital)' '(Resolution-SD)' '(Vacation)' '(Hammer-Hybrid)')
for x in "${exclude[@]}";
do prename -v 's/$x/_/g' * {} \;
done
This for loop does not work at all, and I'm not sure if I can pass a variable to prename. I would like to put the names in an array since I currently have more than 200 that i would like to remove. This list will grow as I restore these files from old backups.
https://redd.it/ytqnsb
@r_bash
reddit
Bash noscript to rename files excluding names in an array
I currenlty have a noscript where I rename files by removing whitespace and certain names. prename -v 's/ /_/g' * prename -v 's/_-_/_/g'...
ASCII Pendulum written in BASH noscript
I am so excited to share my BASH ASCII graphics library.
Been working on it for a while and its finally working.
I made a ASCII pendulum using it.
I've named the library - baSHed2D
Tbh the whole logic of pendulum was copied from coding train YouTube channel's p5.js pendulum video😅
Here's the Demo Video
YouTube link
Ans here's the code
GitHub link
Please review my code and suggestions are welcomed and I actually need some suggestions to improve this.
What you can do using baSHed2D
Draw lines,
Draw circles,
Draw rectangle,
Move these shapes
I will add mouse location getters too.
And a huge thanks to you guys, i had some issues regarding my code and I posted it here. It was for the line drawing algorithm, you guys are great. I learnt so much from your advices.
https://redd.it/ytriej
@r_bash
I am so excited to share my BASH ASCII graphics library.
Been working on it for a while and its finally working.
I made a ASCII pendulum using it.
I've named the library - baSHed2D
Tbh the whole logic of pendulum was copied from coding train YouTube channel's p5.js pendulum video😅
Here's the Demo Video
YouTube link
Ans here's the code
GitHub link
Please review my code and suggestions are welcomed and I actually need some suggestions to improve this.
What you can do using baSHed2D
Draw lines,
Draw circles,
Draw rectangle,
Move these shapes
I will add mouse location getters too.
And a huge thanks to you guys, i had some issues regarding my code and I posted it here. It was for the line drawing algorithm, you guys are great. I learnt so much from your advices.
https://redd.it/ytriej
@r_bash
YouTube
ASCII Pendulum | BASH Script | baSHed2D
Code : https://github.com/adi3120/baSHed2D/blob/main/game.sh
Correct way to insert text in columns
I have this Columns in a text file.
Lets say i would like to add a column to Countries or Numbers or Cities.
What would be the correct way to do this?
I've tried this, to insert in the second column.
printf '%-20s' 'Stockholm' | paste -d "\\t" /file.txt -
Numbers Cities Countries
232323 blahblah waeawewae
232323 blahdadad waeawewaew
123123 asdsadads waewaewaea
123123 asdasdasd waeaweawea
​
https://redd.it/ytw075
@r_bash
I have this Columns in a text file.
Lets say i would like to add a column to Countries or Numbers or Cities.
What would be the correct way to do this?
I've tried this, to insert in the second column.
printf '%-20s' 'Stockholm' | paste -d "\\t" /file.txt -
Numbers Cities Countries
232323 blahblah waeawewae
232323 blahdadad waeawewaew
123123 asdsadads waewaewaea
123123 asdasdasd waeaweawea
​
https://redd.it/ytw075
@r_bash
reddit
Correct way to insert text in columns
I have this Columns in a text file. Lets say i would like to add a column to Countries or Numbers or Cities. What would be the correct way to do...
Running bash noscript from outside Terminal, won't pick up second flag ¯\_(ツ)_/¯
Hi,
I'm running a noscript from Lingon X, a scheduler on macos. It generally works but ignores the *--cuesheet* flag. Can anyone see why?
Lingon X uses this command:
/bin/bash -li /Users/goggle-moggle/iplayer.sh
The iplayer.sh noscript looks like this:
#!/bin/bash
shopt -s expand_aliases
alias gip='get_iplayer --file-prefix="<name> - <episode> <pid> <version>" --pid '
gip m000b075 --pid-recursive --cuesheet
gip b09ymqm4 --pid-recursive --cuesheet
The noscript works as expected when I run from Terminal.
Thanks!
https://redd.it/ytwsi0
@r_bash
Hi,
I'm running a noscript from Lingon X, a scheduler on macos. It generally works but ignores the *--cuesheet* flag. Can anyone see why?
Lingon X uses this command:
/bin/bash -li /Users/goggle-moggle/iplayer.sh
The iplayer.sh noscript looks like this:
#!/bin/bash
shopt -s expand_aliases
alias gip='get_iplayer --file-prefix="<name> - <episode> <pid> <version>" --pid '
gip m000b075 --pid-recursive --cuesheet
gip b09ymqm4 --pid-recursive --cuesheet
The noscript works as expected when I run from Terminal.
Thanks!
https://redd.it/ytwsi0
@r_bash
reddit
Running bash noscript from outside Terminal, won't pick up second...
Hi, I'm running a noscript from Lingon X, a scheduler on macos. It generally works but ignores the *--cuesheet* flag. Can anyone see why? Lingon X...
Round robin algorithm in bash noscript
Hi everyone. So I just started learning bash noscript a few weeks ago. I got an assignment and I have no idea how to do this. I kinda wrote in C# but I dont know how to write in bash. Can anyone help? below is the prompt
Provide a detailed specification, and design of the bash noscript that will emulate the behaviour of the round robin scheduling algorithm
https://redd.it/ytyxak
@r_bash
Hi everyone. So I just started learning bash noscript a few weeks ago. I got an assignment and I have no idea how to do this. I kinda wrote in C# but I dont know how to write in bash. Can anyone help? below is the prompt
Provide a detailed specification, and design of the bash noscript that will emulate the behaviour of the round robin scheduling algorithm
https://redd.it/ytyxak
@r_bash
reddit
Round robin algorithm in bash noscript
Hi everyone. So I just started learning bash noscript a few weeks ago. I got an assignment and I have no idea how to do this. I kinda wrote in C#...
Check if executable has a live process
How to write a bash noscript which checks periodically specific executable has a live process. Say call it as ./check executable_name
https://redd.it/yu8xvc
@r_bash
How to write a bash noscript which checks periodically specific executable has a live process. Say call it as ./check executable_name
https://redd.it/yu8xvc
@r_bash
reddit
Check if executable has a live process
How to write a bash noscript which checks periodically specific executable has a live process. Say call it as ./check [executable_name]
Scripting Issue - new to noscripting
I'm trying to create a noscript that uses one argument, and only one argument. This argument specifies the number of minutes to count down. It should start with the number of minutes, then count down second by second writing the text "there are x seconds remaining". When there is no time left the noscript should echo "time is over" and then quit.
So far I have this:
!#/bin/bash
for (( COUNTER=$1; COUNTER>0; COUNTER-- )); do sleep 1
echo "there are $COUNTER seconds remaining"
done
echo "time is over"
exit 0
​
​
This noscript counts down by the second if I run "bash noscript 5" it will count down 5 seconds, but I need it to count down 5 minutes, second by second when I do that. Appreciate all help
https://redd.it/yueqeh
@r_bash
I'm trying to create a noscript that uses one argument, and only one argument. This argument specifies the number of minutes to count down. It should start with the number of minutes, then count down second by second writing the text "there are x seconds remaining". When there is no time left the noscript should echo "time is over" and then quit.
So far I have this:
!#/bin/bash
for (( COUNTER=$1; COUNTER>0; COUNTER-- )); do sleep 1
echo "there are $COUNTER seconds remaining"
done
echo "time is over"
exit 0
​
​
This noscript counts down by the second if I run "bash noscript 5" it will count down 5 seconds, but I need it to count down 5 minutes, second by second when I do that. Appreciate all help
https://redd.it/yueqeh
@r_bash
reddit
Scripting Issue - new to noscripting
I'm trying to create a noscript that uses one argument, and only one argument. This argument specifies the number of minutes to count down. It...