Creating file from each line in a list?
If i have list in a text file how can i create separate file for each line and insert the line in the text file? For example, if i have this list:
first line
second line
third line
forth line
I want to create four files and insert the text from each line in the file, but i don't want the name of the files to be as the name of the lines of text. Also, i want to add number to each file in increasing order. For example, i want the files to look like this:
file 1.txt
file 2.txt
file 3.txt
file 4.txt
https://redd.it/yc6f17
@r_bash
If i have list in a text file how can i create separate file for each line and insert the line in the text file? For example, if i have this list:
first line
second line
third line
forth line
I want to create four files and insert the text from each line in the file, but i don't want the name of the files to be as the name of the lines of text. Also, i want to add number to each file in increasing order. For example, i want the files to look like this:
file 1.txt
file 2.txt
file 3.txt
file 4.txt
https://redd.it/yc6f17
@r_bash
reddit
Creating file from each line in a list?
If i have list in a text file how can i create separate file for each line and insert the line in the text file? For example, if i have this list:...
How to find content in a file and replace the next string
Using bash how do I find a string and update the string next to it for example pass value
`my.site.com`
proxy_pass.map
my.site2.com test2.spin:80
my.site.com test.spin:8080;
Expected output is to update proxy_pass.map with
my.site2.com test2.spin:80
my.site.com test2.spin:80;
I tried using awk
awk '{gsub(/\^my\\.site\\.com\\s+[A-Za-z0-9\]+\\.spin:8080;$/,"my.site2.comtest2.spin:80"); print}' proxy_pass.map
but does not seem to work. Is there a better way to approch the problem. ?
https://redd.it/yc9jk3
@r_bash
Using bash how do I find a string and update the string next to it for example pass value
`my.site.com`
|test2.spin:80proxy_pass.map
my.site2.com test2.spin:80
my.site.com test.spin:8080;
Expected output is to update proxy_pass.map with
my.site2.com test2.spin:80
my.site.com test2.spin:80;
I tried using awk
awk '{gsub(/\^my\\.site\\.com\\s+[A-Za-z0-9\]+\\.spin:8080;$/,"my.site2.comtest2.spin:80"); print}' proxy_pass.map
but does not seem to work. Is there a better way to approch the problem. ?
https://redd.it/yc9jk3
@r_bash
Writing bash code for array with multiple values
I have a json file which i'm using bash to extract.
sample.json
{"extract": { "data": {"name": "John Smith", "id": 8752, "address": "1 Anywhere Street", "tel": 1234567890, "email": "john.smith@gmail.com" }, { "name": "Jane Smith", "id": 4568, "address": "719 Anywhere Street", "tel": 0987654321, "email": "janesmith@hotmail.com" } } }
and store the value within an array
id=($(cat sample.json | jq -r '.extract.data .name'))
so in the case of
I am intending to store the values in a database (this will be my first attempt) which will be in a similar to that of the json, each object needs to be relative to how it is in the json so it might be better to go with:
data1=($(cat sample.json | jq -r '.extract.data0 | .))
Lets say i have 1000 names to save to my database along with their id's. I'm some advice whether if there a more sensible (more effective) approach on how:
\- Pull the data from Json? will I need to write this 1000 times?e.g
data1=($(cat sample.json | jq -r '.extract.data0 | .))
data2=($(cat sample.json | jq -r '.extract.data1 | .))
data3=($(cat sample.json | jq -r '.extract.data2 | .))
..
data1=($(cat sample.json | jq -r '.extract.data1000 | .))
\-Put the data into the DB from the first array? will the code need to reference the array as:
${data10}
${data11}
${data12}
Would be grateful for a steer in the right direction? - thanks.
https://redd.it/ycexmq
@r_bash
I have a json file which i'm using bash to extract.
sample.json
{"extract": { "data": {"name": "John Smith", "id": 8752, "address": "1 Anywhere Street", "tel": 1234567890, "email": "john.smith@gmail.com" }, { "name": "Jane Smith", "id": 4568, "address": "719 Anywhere Street", "tel": 0987654321, "email": "janesmith@hotmail.com" } } }
and store the value within an array
id=($(cat sample.json | jq -r '.extract.data .name'))
so in the case of
${id[0]} will output John Smith and ${id[1]} will output Jane Smith.I am intending to store the values in a database (this will be my first attempt) which will be in a similar to that of the json, each object needs to be relative to how it is in the json so it might be better to go with:
data1=($(cat sample.json | jq -r '.extract.data0 | .))
Lets say i have 1000 names to save to my database along with their id's. I'm some advice whether if there a more sensible (more effective) approach on how:
\- Pull the data from Json? will I need to write this 1000 times?e.g
data1=($(cat sample.json | jq -r '.extract.data0 | .))
data2=($(cat sample.json | jq -r '.extract.data1 | .))
data3=($(cat sample.json | jq -r '.extract.data2 | .))
..
data1=($(cat sample.json | jq -r '.extract.data1000 | .))
\-Put the data into the DB from the first array? will the code need to reference the array as:
${data10}
${data11}
${data12}
Would be grateful for a steer in the right direction? - thanks.
https://redd.it/ycexmq
@r_bash
reddit
Writing bash code for array with multiple values
I have a json file which i'm using bash to extract. sample.json {"extract": { "data": [ {"name": "John Smith", "id": 8752, "address": "1...
Does Bash have something like Powershell's MenuComplete?
Powershell has a completion function called MenuComplete which displays all completion options and lets you select using the arrow keys. Typing more also narrows down the options. Is there a similar feature in Bash, or is there another shell that can do this?
https://i.stack.imgur.com/nbOkY.gif
https://redd.it/yclc9h
@r_bash
Powershell has a completion function called MenuComplete which displays all completion options and lets you select using the arrow keys. Typing more also narrows down the options. Is there a similar feature in Bash, or is there another shell that can do this?
https://i.stack.imgur.com/nbOkY.gif
https://redd.it/yclc9h
@r_bash
Command out to var
Hi all,
Have experience with noscripting but stumped a bit on bash...
I want to run a command and parse the output to see if someone is logged into a system...
The command is "oc whoami". I thought this would work...
checkLogin=$(oc whoami)
But it still outputs the command when it is run. I tried this but then the var is empty and the output still happens...
checkLogin=$(oc whoami >/dev/null)
Also tried putting the redirect to Dev null outside the parentheses but still get output and blank var
Please help!
https://redd.it/ycqaru
@r_bash
Hi all,
Have experience with noscripting but stumped a bit on bash...
I want to run a command and parse the output to see if someone is logged into a system...
The command is "oc whoami". I thought this would work...
checkLogin=$(oc whoami)
But it still outputs the command when it is run. I tried this but then the var is empty and the output still happens...
checkLogin=$(oc whoami >/dev/null)
Also tried putting the redirect to Dev null outside the parentheses but still get output and blank var
Please help!
https://redd.it/ycqaru
@r_bash
reddit
Command out to var
Hi all, Have experience with noscripting but stumped a bit on bash... I want to run a command and parse the output to see if someone is logged...
How to read integer from 32-bit message length in native byte order (Uint32Array)?
I am using this
read -rn 1 uint32
# https://unix.stackexchange.com/a/13141
header=0x$(printf "%s" "${uint32:3:1}${uint32:2:1}${uint32:1:1}${uint32:0:1}" |
od -t x1 -An |
tr -dc ':alnum:')
# https://stackoverflow.com/users/1501388/lashgar
messageLength=$(printf "%d" "$header")
echo "$messageLength" >>length.txt
to read
> 32-bit message length in native byte order
to get message length from client in host https://developer.chrome.com/docs/apps/nativeMessaging/#native-messaging-host-protocol.
The issue arises when I pass an
2036 // new Array(407)
2041 // new Array(408)
254 // new Array(409)
108
117
44
44
44
//
with the next 32 lines printing
What do I need to change in
https://redd.it/ycuaox
@r_bash
I am using this
read -rn 1 uint32
# https://unix.stackexchange.com/a/13141
header=0x$(printf "%s" "${uint32:3:1}${uint32:2:1}${uint32:1:1}${uint32:0:1}" |
od -t x1 -An |
tr -dc ':alnum:')
# https://stackoverflow.com/users/1501388/lashgar
messageLength=$(printf "%d" "$header")
echo "$messageLength" >>length.txt
to read
> 32-bit message length in native byte order
to get message length from client in host https://developer.chrome.com/docs/apps/nativeMessaging/#native-messaging-host-protocol.
The issue arises when I pass an
Array() with length 409 or greated from JavaScript whic is converted to JSON by the application.2036 // new Array(407)
2041 // new Array(408)
254 // new Array(409)
108
117
44
44
44
//
with the next 32 lines printing
44. What do I need to change in
od, tr, printf commands to read more than 2041 character length correctly and convert to an integer?https://redd.it/ycuaox
@r_bash
Unix & Linux Stack Exchange
In bash, how to convert 8 bytes to an unsigned int (64bit LE)?
How can I 'read/interpret' 8 bytes as an unsigned int (Little Endian)?
Perhaps there is a Bash-fu magic conversion for this?
UPDATE:
It seems that something got cross-wired in the interpretation ...
Perhaps there is a Bash-fu magic conversion for this?
UPDATE:
It seems that something got cross-wired in the interpretation ...
very new to noscripting/bash
Hi!
I am very new to bash and noscripting and a student. I am doing an assignment where I have to compare two files dates.
So i prompt user for two file names - check to see if valid files - compare dates and list which file is older - if the files have the same date then display a message saying they're the same.
​
I am working with very basic commands. so only using if/while/for statements so far.
​
echo -n "Enter a files name: "
read firstfile
echo -n "Enter another file name: "
read secondfile
​
if [ -f $firstfile \] && [ -f $secondfile \]
then
if [ "$firstfile" -nt "$secondfile" \]
then
echo $secondfile "is older"
fi
if [ "$firstfile" -ot "$secondfile" \]
then
echo $firstfile "is older"
fi
else
echo "Invalid file/s name"
fi
​
this is what I have so far, but I'm struggling with a prompt to tell if the dates are the same. If there is any guidance or a source I could read, it would be very helpful.
​
Thanks
https://redd.it/ycy6ey
@r_bash
Hi!
I am very new to bash and noscripting and a student. I am doing an assignment where I have to compare two files dates.
So i prompt user for two file names - check to see if valid files - compare dates and list which file is older - if the files have the same date then display a message saying they're the same.
​
I am working with very basic commands. so only using if/while/for statements so far.
​
echo -n "Enter a files name: "
read firstfile
echo -n "Enter another file name: "
read secondfile
​
if [ -f $firstfile \] && [ -f $secondfile \]
then
if [ "$firstfile" -nt "$secondfile" \]
then
echo $secondfile "is older"
fi
if [ "$firstfile" -ot "$secondfile" \]
then
echo $firstfile "is older"
fi
else
echo "Invalid file/s name"
fi
​
this is what I have so far, but I'm struggling with a prompt to tell if the dates are the same. If there is any guidance or a source I could read, it would be very helpful.
​
Thanks
https://redd.it/ycy6ey
@r_bash
reddit
very new to noscripting/bash
Hi! I am very new to bash and noscripting and a student. I am doing an assignment where I have to compare two files dates. So i prompt user...
Unconfusing my brain
Why
alias same='diff '
so that I can write
if same file1 file2; then
echo the files are the same
fi
and
if ! same file1 file2; then
echo the file are different
fi
https://redd.it/yd5wuu
@r_bash
Why
diff returns 1 (which is "false" in shell) when files differ is beyond me. In order to unconfuse my brain, I do this:alias same='diff '
so that I can write
if same file1 file2; then
echo the files are the same
fi
and
if ! same file1 file2; then
echo the file are different
fi
https://redd.it/yd5wuu
@r_bash
reddit
Unconfusing my brain
Why `diff` returns 1 (which is "false" in shell) when files differ is beyond me. In order to unconfuse my brain, I do this: alias same='diff...
TUI noscript launcher? Help with noscripting needed.
I have A LOT of doom mods on my PC and for each game/mod I've created its own launch bash noscript and added it to my path along with a ton of other games.
This setup is cluttering my tab autocomplete so I came up with an idea of a simple and bloat free noscript launcher.
It basically looks like this:
- Upon launching the program, you are greeted with just a list of noscripts inside an assigned directory.
- Launching noscripts is done with enter key and I can scroll up and down with arrow keys.
- After I press enter and launch one of numerous noscripts, program exits and closes a terminal along with it.
- Adding new noscripts is done simply by putting them in the designated noscript folder and restarting the program.
I know of a few tui file managers, I am guessing you could probably configure it to open in a specific directory, but I do not want to do that.
Or even better, the little tui program I came up with written in bash, or whatever, already exists and all I need is to download it, then please point me in the right direction. Google search has failed me, sorry, didn't find what I am looking for.
In case there is no such simple tui launcher for me can you perhaps help me write one? I am new to bash noscripting.
https://redd.it/ydbvmr
@r_bash
I have A LOT of doom mods on my PC and for each game/mod I've created its own launch bash noscript and added it to my path along with a ton of other games.
This setup is cluttering my tab autocomplete so I came up with an idea of a simple and bloat free noscript launcher.
It basically looks like this:
- Upon launching the program, you are greeted with just a list of noscripts inside an assigned directory.
- Launching noscripts is done with enter key and I can scroll up and down with arrow keys.
- After I press enter and launch one of numerous noscripts, program exits and closes a terminal along with it.
- Adding new noscripts is done simply by putting them in the designated noscript folder and restarting the program.
I know of a few tui file managers, I am guessing you could probably configure it to open in a specific directory, but I do not want to do that.
Or even better, the little tui program I came up with written in bash, or whatever, already exists and all I need is to download it, then please point me in the right direction. Google search has failed me, sorry, didn't find what I am looking for.
In case there is no such simple tui launcher for me can you perhaps help me write one? I am new to bash noscripting.
https://redd.it/ydbvmr
@r_bash
reddit
TUI noscript launcher? Help with noscripting needed.
I have A LOT of doom mods on my PC and for each game/mod I've created its own launch bash noscript and added it to my path along with a ton of other...
help removing whitespace
I am trying to remove parenthesis and everything within them. Ive accomplished that much, but when I do this, it adds an extra space where the parenthesis used to be. Any ideas on how to delete that space?
here is what im using (its in a sed noscript):
s/\(.*\)//g
https://redd.it/yde3fi
@r_bash
I am trying to remove parenthesis and everything within them. Ive accomplished that much, but when I do this, it adds an extra space where the parenthesis used to be. Any ideas on how to delete that space?
here is what im using (its in a sed noscript):
s/\(.*\)//g
https://redd.it/yde3fi
@r_bash
reddit
help removing whitespace
I am trying to remove parenthesis and everything within them. Ive accomplished that much, but when I do this, it adds an extra space where the...
How to remove all kind of spaces using sed command.
How do i remove all kind of spaces (empty new lines, tab spaces, normal space, etc) using sed command.
Hello how are you?
​
Hi
Sup
After the command execution the output should be:
Hello how are you?
Hi
Sup
https://redd.it/ydo1rb
@r_bash
How do i remove all kind of spaces (empty new lines, tab spaces, normal space, etc) using sed command.
Hello how are you?
​
Hi
Sup
After the command execution the output should be:
Hello how are you?
Hi
Sup
https://redd.it/ydo1rb
@r_bash
reddit
How to remove all kind of spaces using sed command.
How do i remove all kind of spaces (empty new lines, tab spaces, normal space, etc) using sed command. Hello how are you? Hi ...
Lorem Ipsum generator for Shin
I got so excited about Shin, this new tool that allows you to run bash everywhere, that I started making myself some noscripts.
First one is a simple lorem ipsum generator, super useful for designers like me :)
#!/bin/bash
# set -x
string="lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua velit egestas dui id ornare arcu odio ut sem nulla lorem sed risus ultricies tristique nulla aliquet enim tortor at nibh sed pulvinar proin gravida hendrerit lectus a risus sed vulputate odio ut enim cursus euismod quis viverra nibh cras pulvinar quis enim lobortis scelerisque fermentum dui faucibus in ornare dictumst vestibulum rhoncus est pellentesque elit blandit cursus risus at ultrices mi tempus nulla pharetra diam sit amet nisl suscipit adipiscing"
# Make the string an array
words=($string)
# Shuffle the array and grab the first 12 indices
# You could pass $1 instead if you want control
words=( $(shuf -e "${words@}" | head -12) )
# Capitalize the first letter.
words="${words^}"
printf "%s " "${words@}."
https://redd.it/ydqjl5
@r_bash
I got so excited about Shin, this new tool that allows you to run bash everywhere, that I started making myself some noscripts.
First one is a simple lorem ipsum generator, super useful for designers like me :)
#!/bin/bash
# set -x
string="lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua velit egestas dui id ornare arcu odio ut sem nulla lorem sed risus ultricies tristique nulla aliquet enim tortor at nibh sed pulvinar proin gravida hendrerit lectus a risus sed vulputate odio ut enim cursus euismod quis viverra nibh cras pulvinar quis enim lobortis scelerisque fermentum dui faucibus in ornare dictumst vestibulum rhoncus est pellentesque elit blandit cursus risus at ultrices mi tempus nulla pharetra diam sit amet nisl suscipit adipiscing"
# Make the string an array
words=($string)
# Shuffle the array and grab the first 12 indices
# You could pass $1 instead if you want control
words=( $(shuf -e "${words@}" | head -12) )
# Capitalize the first letter.
words="${words^}"
printf "%s " "${words@}."
https://redd.it/ydqjl5
@r_bash
reddit
I made a tool that lets you run shell commands from any text input...
Posted in r/linux by u/-p-e-w- • 1 point and 0 comments
Getting user shell via username
How can I write an if statement that checks what shell a user uses
I tried somthing like that but it didn't work
awk -F: '{ if ($3 >= 1000 && $3 <= 60000) { print $1, $7 } }' /etc/passwd | grep -q "$username /bin/sh"
if [ "$?" = "$username /bin/sh" ] ; then
echo "sh"
else
echo "bash"
fi
any help would be appricated
https://redd.it/ydsvc3
@r_bash
How can I write an if statement that checks what shell a user uses
I tried somthing like that but it didn't work
awk -F: '{ if ($3 >= 1000 && $3 <= 60000) { print $1, $7 } }' /etc/passwd | grep -q "$username /bin/sh"
if [ "$?" = "$username /bin/sh" ] ; then
echo "sh"
else
echo "bash"
fi
any help would be appricated
https://redd.it/ydsvc3
@r_bash
reddit
Getting user shell via username
How can I write an ``if`` statement that checks what shell a user uses I tried somthing like that but it didn't work `` awk -F: '{ if ($3 >= 1000...
string comparison not working inside while loop
while IFS=',' read -r name position jobs || [ -n "$name" ]
do
if [ ${position} = "bartender" ]; then
echo "$name"
fi
done < "$1"
I have tried set -x, I have tried echoing, I have no idea why it doesn't work. Even when $position clearly contains "bartender", it evaluates to false.
The file looks like this:
Example 1, bartender, A, B, C
Example 2, bartender, C, B, A
https://redd.it/ydur0n
@r_bash
while IFS=',' read -r name position jobs || [ -n "$name" ]
do
if [ ${position} = "bartender" ]; then
echo "$name"
fi
done < "$1"
I have tried set -x, I have tried echoing, I have no idea why it doesn't work. Even when $position clearly contains "bartender", it evaluates to false.
The file looks like this:
Example 1, bartender, A, B, C
Example 2, bartender, C, B, A
https://redd.it/ydur0n
@r_bash
reddit
string comparison not working inside while loop
while IFS=',' read -r name position jobs || [[ -n "$name" ]] do if [[ ${position} = "bartender" ]]; then echo...
Why does new line (\n) is represented with dot (.) in xxd?
e.g.
$ echo -e '..A\n'
..A
$ echo -e '..A\n' | xxd
00000000: 2e2e 410a 0a ..A..
$ echo -e '..A\n' | xxd -c 1
00000000: 2e .
00000001: 2e .
00000002: 41 A
00000003: 0a .
00000004: 0a .
Can't help but keep thinking why does the new line (\\n or 0a) is represented with dot (.) in xxd?
https://redd.it/ydxj4t
@r_bash
e.g.
$ echo -e '..A\n'
..A
$ echo -e '..A\n' | xxd
00000000: 2e2e 410a 0a ..A..
$ echo -e '..A\n' | xxd -c 1
00000000: 2e .
00000001: 2e .
00000002: 41 A
00000003: 0a .
00000004: 0a .
Can't help but keep thinking why does the new line (\\n or 0a) is represented with dot (.) in xxd?
https://redd.it/ydxj4t
@r_bash
reddit
Why does new line (\n) is represented with dot (.) in xxd?
e.g. $ echo -e '..A\n' ..A $ echo -e '..A\n' | xxd 00000000: 2e2e 410a 0a ..A.. $ echo...
killing a process that is spawned from a subsubnoscript
Hi everyone, hope you all doing great.
so a have a
i tried:
1. kill -KILL -
2. pkill -P
but those keep the spawned processes running.
​
https://redd.it/ye10s4
@r_bash
Hi everyone, hope you all doing great.
so a have a
noscript1 which spawn a number of noscript2 as background process.noscript2 spawns noscript3 in noscript3 i run a specific program, i store the process id of noscript3 in a file and retrive it later when needed, at some point i just want to kill the whole program without leaving process behind, how can i do that?noscript3 is spawned from a function in noscript2 and is run as a background process. noscript3_function & i tried:
1. kill -KILL -
noscript3_pid 2. pkill -P
noscript3_pidbut those keep the spawned processes running.
​
https://redd.it/ye10s4
@r_bash
reddit
killing a process that is spawned from a subsubnoscript
Hi everyone, hope you all doing great. so a have a `noscript1` which spawn a number of `noscript2` as background process. `noscript2` spawns `noscript3`...
What is going on here ?
I need an explanation. Looks like an easter egg, lol !
This is fine:
​
But what is going here ? :
Them the program stops, the mouse cursor changes to a doubled cross until I click on the left mouse button.
The question is : From what hell this cursor came from and why my noscript is blocked until I clicked the left mouse button ?
For sure it is related to the
Of course, adding the interpreter line to the noscript, everything works as expected.
​
PS: I had trouble with inline code,,,,things get messy. I hope formatting it is fixed now.
https://redd.it/ye7435
@r_bash
I need an explanation. Looks like an easter egg, lol !
This is fine:
cat > ~/bin/test.py <<EOF#no interpreter lineprint ("hello world.")EOFchmod +x ~/bin/test.py~/bin/test.py/home/miguel/bin/test.py: line 2: syntax error near unexpected token \"hello world."/home/miguel/bin/test.py: line 2: \print ("hello world.")​
But what is going here ? :
cat > ~/bin/test2.py <<EOF# no interpreter lineimport jsonprint ("hello world.")EOFchmod +x ~/bin/test2.py~/bin/test2.pyThem the program stops, the mouse cursor changes to a doubled cross until I click on the left mouse button.
The question is : From what hell this cursor came from and why my noscript is blocked until I clicked the left mouse button ?
For sure it is related to the
import json, but how , why ?Of course, adding the interpreter line to the noscript, everything works as expected.
​
PS: I had trouble with inline code,,,,things get messy. I hope formatting it is fixed now.
https://redd.it/ye7435
@r_bash
reddit
What is going on here ?
I need an explanation. Looks like an easter egg, lol ! This is fine: `cat > ~/bin/test.py <<EOF` `#no interpreter line` `print ("hello...
Need some help massaging some filenames
Hello all,
I have a large number of music files that needs some TLC.
Here is a sample;
'Polygyny - Absentee Husband (Pt. 1)-mH2vMMl3BDg.mp3'
'Primal Scream - 2013 - Full Length - Official-bdCraT9_wk4.mp3'
'Primal Scream - All Fall Down-4wi2bi9-ZUI.mp3'
'Prince - 1999 (Official Music Video)-rblt2EtFfC4.mp3'
'Pulp - After You (Soulwax Remix)-KTuLLBqs4Xg.mp3'
'Robert Wyatt - Arauco-JPbsBPkIAy0.mp3'
'Robert Wyatt - At Last I Am Free-6xQx4G11pRo.mp3'
'Rufus & Chaka Khan - Ain'\\''t Nobody (Official Video) Remastered Audio HQ-hrWTxRgd4Wk.mp3'
'Saint Etienne - Avenue-h05qHruTmb8.mp3'
"Sandkings - All's Well With The World-rf6-5-9efM8.mp3"
'She Was a Vision-o6YyRX5TIYc.mp3'
'Sisters of Mercy - Alice--GwWra1sQgo.mp3'
'Soul II Soul - Back To Life (However Do You Want Me) (Official Music Video)-TB54dZkzZOY.mp3'
I would like to remove anything inside parenthesis, also at the end of every filename there is that random group of characters between a '-' dash and the '.mp3'.
Now, the parenthesis I could probably finagle a solution to, but the random characters I don't know how to do.
Can some bright young bash wiz help out an old man?
https://redd.it/yeknqt
@r_bash
Hello all,
I have a large number of music files that needs some TLC.
Here is a sample;
'Polygyny - Absentee Husband (Pt. 1)-mH2vMMl3BDg.mp3'
'Primal Scream - 2013 - Full Length - Official-bdCraT9_wk4.mp3'
'Primal Scream - All Fall Down-4wi2bi9-ZUI.mp3'
'Prince - 1999 (Official Music Video)-rblt2EtFfC4.mp3'
'Pulp - After You (Soulwax Remix)-KTuLLBqs4Xg.mp3'
'Robert Wyatt - Arauco-JPbsBPkIAy0.mp3'
'Robert Wyatt - At Last I Am Free-6xQx4G11pRo.mp3'
'Rufus & Chaka Khan - Ain'\\''t Nobody (Official Video) Remastered Audio HQ-hrWTxRgd4Wk.mp3'
'Saint Etienne - Avenue-h05qHruTmb8.mp3'
"Sandkings - All's Well With The World-rf6-5-9efM8.mp3"
'She Was a Vision-o6YyRX5TIYc.mp3'
'Sisters of Mercy - Alice--GwWra1sQgo.mp3'
'Soul II Soul - Back To Life (However Do You Want Me) (Official Music Video)-TB54dZkzZOY.mp3'
I would like to remove anything inside parenthesis, also at the end of every filename there is that random group of characters between a '-' dash and the '.mp3'.
Now, the parenthesis I could probably finagle a solution to, but the random characters I don't know how to do.
Can some bright young bash wiz help out an old man?
https://redd.it/yeknqt
@r_bash
reddit
Need some help massaging some filenames
Hello all, I have a large number of music files that needs some TLC. Here is a sample; 'Polygyny - Absentee Husband (Pt....
Special noscript for get full information about any linux system
Hello everybody!I serve a lot of linux system and when I connect to them I want to get simple information about system: hostname, list last commands, information about memory, hardware and other. I wrote a little noscript and I want go get a good critique. Please look at this noscript and give me some advice how I can make this code better, thank you.
My Script: https://pastebin.com/Pv2VZ44B. You can use this noscript, if you like it
A little denoscription about algorithms this noscript:
Get Info about noscript and weather by ip info :) - `curl, l2.io/ip,` [`wttr.in`](https://wttr.in)
Get General Info -
Get Hardware Info - `sudo lshw`
Get Network Info -
Get Memory Info (>!this code i take on the internet - perhaps stackoverflow.com!<) - `ps`
Get Disk Info -
Get Network Trafic Info - (>!this code i take on the internet - perhaps stackoverflow.com!<) - `proc/net/dev`
Get Logins and History Info -
https://redd.it/yemqeo
@r_bash
Hello everybody!I serve a lot of linux system and when I connect to them I want to get simple information about system: hostname, list last commands, information about memory, hardware and other. I wrote a little noscript and I want go get a good critique. Please look at this noscript and give me some advice how I can make this code better, thank you.
My Script: https://pastebin.com/Pv2VZ44B. You can use this noscript, if you like it
A little denoscription about algorithms this noscript:
Get Info about noscript and weather by ip info :) - `curl, l2.io/ip,` [`wttr.in`](https://wttr.in)
Get General Info -
uname, lsb_release, whoami, whoGet Hardware Info - `sudo lshw`
Get Network Info -
ip add showGet Memory Info (>!this code i take on the internet - perhaps stackoverflow.com!<) - `ps`
Get Disk Info -
dfGet Network Trafic Info - (>!this code i take on the internet - perhaps stackoverflow.com!<) - `proc/net/dev`
Get Logins and History Info -
last, lastb, /etc/paswd, historyhttps://redd.it/yemqeo
@r_bash
Bash readline command not recognized
Hey there,
I am currently customizing my inputrc to set new keybindings for the set -o vi mode.
[readline library\]
There is a command list in man(1) bash.
```
previous-screen-line
Attempt to move point to the same physical screen column on the previous physical screen line. This will not have the desired effect if the current readline line does not take up more than one physical line or if point is not greater than the length of the prompt plus the screen width.
next-screen-line
Attempt to move point to the same physical screen column on the next physical screen line. This will not have the desired effect if the current readline line does not take up more than one physical line or if the length of current readline line is not greater than the length of the prompt plus the screen width.
```
All the other commands work as expected. Yet those two do not.
Any1 has any idea why ?
Thanks for your time :)
https://redd.it/yep02s
@r_bash
Hey there,
I am currently customizing my inputrc to set new keybindings for the set -o vi mode.
[readline library\]
There is a command list in man(1) bash.
```
previous-screen-line
Attempt to move point to the same physical screen column on the previous physical screen line. This will not have the desired effect if the current readline line does not take up more than one physical line or if point is not greater than the length of the prompt plus the screen width.
next-screen-line
Attempt to move point to the same physical screen column on the next physical screen line. This will not have the desired effect if the current readline line does not take up more than one physical line or if the length of current readline line is not greater than the length of the prompt plus the screen width.
```
All the other commands work as expected. Yet those two do not.
Any1 has any idea why ?
Thanks for your time :)
https://redd.it/yep02s
@r_bash
reddit
Bash readline command not recognized
Hey there, I am currently customizing my inputrc to set new keybindings for the set -o vi mode. \[readline library\] There is a command list in...
getopts switches
Created a noscript which is using getopts,and has 4 switches -> 3,p,d and h. How could I limit the usage to something like:
- if h is used, no other switch should be used
- switch 3 and p should not be used together
I would like to know if there's way of accomplishing this without using tests outside the while loop.
Thanks
https://redd.it/yetohi
@r_bash
Created a noscript which is using getopts,and has 4 switches -> 3,p,d and h. How could I limit the usage to something like:
- if h is used, no other switch should be used
- switch 3 and p should not be used together
I would like to know if there's way of accomplishing this without using tests outside the while loop.
Thanks
https://redd.it/yetohi
@r_bash
reddit
getopts switches
Created a noscript which is using getopts,and has 4 switches -> 3,p,d and h. How could I limit the usage to something like: - if h is used, no...