Unable to understand the usage of jq while indexing
I am pretty much new to bash and learning to noscript well, I am learning how to use jq tool to parse a json file and access the elements of character by character.
https://pastebin.com/SfLFbJPE
In this effort, my code works fine I have the item to be "DOG"
and my for loop to have
for entry in $(echo "$json_data" | jq '.[\] | select(.[\] | contains("D"))'); do
where the key comes out to be 2 but when i access dynamically with ${item:$j:1} its not going to the for loop itself. Could someone help me understand this thing?
for entry in $(echo "$json_data" | jq '.[\] | select(.[\] | contains("${item:$j:1}"))'); do
https://redd.it/1ce7xo8
@r_bash
I am pretty much new to bash and learning to noscript well, I am learning how to use jq tool to parse a json file and access the elements of character by character.
https://pastebin.com/SfLFbJPE
In this effort, my code works fine I have the item to be "DOG"
and my for loop to have
for entry in $(echo "$json_data" | jq '.[\] | select(.[\] | contains("D"))'); do
where the key comes out to be 2 but when i access dynamically with ${item:$j:1} its not going to the for loop itself. Could someone help me understand this thing?
for entry in $(echo "$json_data" | jq '.[\] | select(.[\] | contains("${item:$j:1}"))'); do
https://redd.it/1ce7xo8
@r_bash
Pastebin
#!/usr/bin/env bashcheck_scrabble(){ local score=0 local j - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I want to read more about jq(preferred books)
Can you guide me some? I am till now not finding a book that contains at least 10 pages on jq.
https://redd.it/1ce8lim
@r_bash
Can you guide me some? I am till now not finding a book that contains at least 10 pages on jq.
https://redd.it/1ce8lim
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
what is the difference between absolute and relative path in the bash shell?
Hello, i'm trying to understand what the difference between a relative path and an absolute path is in the bash shell
i did a reddit search of r/bash and found this
https://www.reddit.com/r/bash/comments/4aam9w/can\_someone\_tell\_me\_the\_difference\_between/
but i'm not really understanding what they are talking about in the context of the bash shell
can anyone give me any examples of the difference between an absolute path and a relative path that i can actually use in my shell so i myself can get a handle on the concept?
thank you
https://redd.it/1cedn73
@r_bash
Hello, i'm trying to understand what the difference between a relative path and an absolute path is in the bash shell
i did a reddit search of r/bash and found this
https://www.reddit.com/r/bash/comments/4aam9w/can\_someone\_tell\_me\_the\_difference\_between/
but i'm not really understanding what they are talking about in the context of the bash shell
can anyone give me any examples of the difference between an absolute path and a relative path that i can actually use in my shell so i myself can get a handle on the concept?
thank you
https://redd.it/1cedn73
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Whats the best resource to learn bash?
I wanna know what's the best resource to learn bash noscripting.
And for cyber security which one is better bash or zsh?
https://redd.it/1cf19sy
@r_bash
I wanna know what's the best resource to learn bash noscripting.
And for cyber security which one is better bash or zsh?
https://redd.it/1cf19sy
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Using a launcher/.desktop file to run a bash noscript in the same folder as the launcher?
Hi,
I made a bash noscript called "AppendDate.sh" which simply appends the modification date to the filenames of any drag and dropped files. Since I can't drag and drop files directly onto .sh files, to run this noscript, I am using a launcher to indirectly run it.
The launcher works if I use a an absolute path for the noscript combined with $1 for the dropped file(s). But I would like to use a relative path in the launcher instead, so that the solution is more "portable".
On other internet pages, I have read that an Exec command like the following should work:
sh -e -c "exec \\\\"\\\\$(dirname \\\\"\\\\$0\\\\")/AppendDate.sh\\\\"" %k
But this isn't working for me, no matter where I try to add $1 (or \\\\$1).
Any ideas?
https://redd.it/1cf5hpw
@r_bash
Hi,
I made a bash noscript called "AppendDate.sh" which simply appends the modification date to the filenames of any drag and dropped files. Since I can't drag and drop files directly onto .sh files, to run this noscript, I am using a launcher to indirectly run it.
The launcher works if I use a an absolute path for the noscript combined with $1 for the dropped file(s). But I would like to use a relative path in the launcher instead, so that the solution is more "portable".
On other internet pages, I have read that an Exec command like the following should work:
sh -e -c "exec \\\\"\\\\$(dirname \\\\"\\\\$0\\\\")/AppendDate.sh\\\\"" %k
But this isn't working for me, no matter where I try to add $1 (or \\\\$1).
Any ideas?
https://redd.it/1cf5hpw
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
what is a "shell language" in the context of other programming languages?
question, what is a "shell language" in the context of other programming languages?
i keep hearing the term "shell language" but when i google it i just get "shell noscript" but people keep using this term "shell language" as if it's some how different in the context of other programming languages
any ideas?
thank you
https://redd.it/1cf79a7
@r_bash
question, what is a "shell language" in the context of other programming languages?
i keep hearing the term "shell language" but when i google it i just get "shell noscript" but people keep using this term "shell language" as if it's some how different in the context of other programming languages
any ideas?
thank you
https://redd.it/1cf79a7
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
what is an "argument" in bash?
Hello, so i did a search of r/bash and i asked "what is an argument" and i got this result
https://www.reddit.com/r/bash/search/?q=arguement&type=link&cId=690c4a5d-257a-4bc3-984a-1cb53331a300&iId=9528a6b6-c3f6-4cbb-9afe-2e739935c053
and i got a lot of posts about modifying arguments, but what i noticed is i couldn't find any explanation of what an argument is, so i wanted to take this moment to ask.
what is an argument in bash? what does an argument mean?
thank you
https://redd.it/1cfbc6r
@r_bash
Hello, so i did a search of r/bash and i asked "what is an argument" and i got this result
https://www.reddit.com/r/bash/search/?q=arguement&type=link&cId=690c4a5d-257a-4bc3-984a-1cb53331a300&iId=9528a6b6-c3f6-4cbb-9afe-2e739935c053
and i got a lot of posts about modifying arguments, but what i noticed is i couldn't find any explanation of what an argument is, so i wanted to take this moment to ask.
what is an argument in bash? what does an argument mean?
thank you
https://redd.it/1cfbc6r
@r_bash
I use bash: is "ls -d /" the best way to see only the dirs/ into a dir?
Hi, I use bash terminal, and I found by trying that the command ls -d / is the way mode to see only the dirs into another dir, excluding the files.
Do you know another command for filter only the dir/ ?
Thank you and regards!
https://redd.it/1cfl0jq
@r_bash
Hi, I use bash terminal, and I found by trying that the command ls -d / is the way mode to see only the dirs into another dir, excluding the files.
Do you know another command for filter only the dir/ ?
Thank you and regards!
https://redd.it/1cfl0jq
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Who implements the features of bash ?
Bash works on any kind of processor and any operating system. when i execute 'ls' it works both on windows and linux even though both use completely different file systems ? so who implements the features of bash ?
Is bash just a specification and each os / motherboard manufactures implements it according to the specification ?
https://redd.it/1cfrwut
@r_bash
Bash works on any kind of processor and any operating system. when i execute 'ls' it works both on windows and linux even though both use completely different file systems ? so who implements the features of bash ?
Is bash just a specification and each os / motherboard manufactures implements it according to the specification ?
https://redd.it/1cfrwut
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Avoid 100% cpu when I read a FIFO file
Hi!
I need to read FIFO file, because it arrives a log of snmp traps in the FIFO file that I need to read and process them sequentially.
So I've created a while (true) loop to begin to read lines of FIFO file and process the output. Problem is machine increase cpu up 100% with the use of the noscript.
I don't know if I put a sleep 3s for example in noscript. Should it read all lines of fifo file or could be that it doesn't read all lines?
Thanks and sorry for my English!
https://redd.it/1cfy6gf
@r_bash
Hi!
I need to read FIFO file, because it arrives a log of snmp traps in the FIFO file that I need to read and process them sequentially.
So I've created a while (true) loop to begin to read lines of FIFO file and process the output. Problem is machine increase cpu up 100% with the use of the noscript.
I don't know if I put a sleep 3s for example in noscript. Should it read all lines of fifo file or could be that it doesn't read all lines?
Thanks and sorry for my English!
https://redd.it/1cfy6gf
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
A bash noscript that's purpose is to source the latest version of a GitHub repository
# Get the Latest Version of Any Git Repository
Easily retrieve the latest version of any Git repository with a simple bash noscript!
## Usage
1. Set the
2. Create a variable to store the repository version and echo its value:
Or use this shorter command:
## Other Execution Methods
## The main noscript
You can see the noscript here
## Test It Out
Check out this bash noscript to see the noscript in action with various examples!
https://redd.it/1cgizdv
@r_bash
# Get the Latest Version of Any Git Repository
Easily retrieve the latest version of any Git repository with a simple bash noscript!
## Usage
1. Set the
url variable in your bash noscript to the URL of the repository you want to clone:url="https://github.com/rust-lang/rust.git"
2. Create a variable to store the repository version and echo its value:
repo_version=$(curl -fsS "https://raw.githubusercontent.com/slyfox1186/noscript-repo/main/Bash/Misc/source-git-repo-version.sh" | bash -s "$url")
echo "$repo_version"
Or use this shorter command:
repo_version=$(curl -fsSL "https://gitver.optimizethis.net" | bash -s "$url")
echo "$repo_version"
## Other Execution Methods
./source-git-repo-version.sh "https://github.com/rust-lang/rust.git"
## The main noscript
You can see the noscript here
## Test It Out
Check out this bash noscript to see the noscript in action with various examples!
https://redd.it/1cgizdv
@r_bash
GitHub
noscript-repo/Bash/Misc/source-git-repo-version.sh at main · slyfox1186/noscript-repo
My personal noscript repository with multiple languages supported. AHK v1+v2 | BASH | BATCH | JSON | POWERSHELL | POWERSHELL | PYTHON | WINDOWS REGISTRY | XML - slyfox1186/noscript-repo
A bash noscript that's purpose is to source the latest version of a GitHub repository
# Get the Latest Version of Any Git Repository
Easily retrieve the latest version of any Git repository with a simple bash noscript!
## Usage
1. Set the
2. Create a variable to store the repository version and echo its value:
Or use this shorter command:
## Test It Out
Check out this bash noscript to see the noscript in action with various examples!
https://redd.it/1cgiz2e
@r_bash
# Get the Latest Version of Any Git Repository
Easily retrieve the latest version of any Git repository with a simple bash noscript!
## Usage
1. Set the
url variable in your bash noscript to the URL of the repository you want to clone:url="https://github.com/rust-lang/rust.git"
2. Create a variable to store the repository version and echo its value:
repo_version=$(curl -fsS "https://raw.githubusercontent.com/slyfox1186/noscript-repo/main/Bash/Misc/source-git-repo-version.sh" | bash -s "$url")
echo "$repo_version"
Or use this shorter command:
repo_version=$(curl -fsSL "https://gitver.optimizethis.net" | bash -s "$url")
echo "$repo_version"
## Test It Out
Check out this bash noscript to see the noscript in action with various examples!
https://redd.it/1cgiz2e
@r_bash
GitHub
noscript-repo/Bash/Misc/git-repo-test.sh at main · slyfox1186/noscript-repo
My personal noscript repository with multiple languages supported. AHK v1+v2 | BASH | BATCH | JSON | POWERSHELL | POWERSHELL | PYTHON | WINDOWS REGISTRY | XML - slyfox1186/noscript-repo
DriveTool.sh: A Script for Rapid and Secure File Copying to USB Flash Drives
Hello everyone,
In Linux, files are permanently written only after the partition is unmounted. This might explain why many graphical tools deliver unsatisfactory performance when writing files to USB flash drives. To address this issue, I have developed a compact noscript which, thus far, has performed effectively.
Note: I was unable to get the status=progress feature to function correctly. However, the noscript successfully copies the transferred files to the USB flash drive. After conducting multiple tests, no errors were encountered.
#!/bin/bash
declare -r MOUNT_POINT="/media/flashdrive"
# Function to check for required commands
check_dependencies() {
local dependencies=(lsblk mkdir mount umount dd cp du grep diff)
for cmd in "${dependencies[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
echo "Error: Required command '$cmd' is not installed." >&2
exit 1
fi
done
}
# Function to check if device is mounted and unmount it
safe_unmount() {
local device="$1"
if mount | grep -qw "$device"; then
echo "$device is currently mounted, attempting to unmount..."
sudo umount "$device" && echo "$device unmounted successfully." || { echo "Failed to unmount $device."; return 1; }
fi
}
# Function to mount drive
ensure_mounted() {
local device="$1"
if ! mount | grep -q "$MOUNT_POINT"; then
echo "Mounting $device..."
sudo mkdir -p "$MOUNT_POINT"
sudo mount "$device" "$MOUNT_POINT" || { echo "Failed to mount $device."; exit 1; }
else
echo "Device is already mounted on $MOUNT_POINT."
fi
}
# Function to copy files or directories safely
copy_files() {
local source="$1"
local destination="$2"
local dest_path="$destination/$(basename "$source")"
if [[ -d "$source" ]]; then
echo "Copying directory $source to $destination using 'cp -r'..."
sudo cp -r "$source" "$dest_path" && echo "$source has been copied."
else
echo "Copying file $source to $destination using 'dd'..."
sudo dd if="$source" of="$dest_path" bs=4M status=progress && echo "$source has been copied."
fi
echo "Wait finishing changes..."
sudo mount -o remount,sync "$MOUNT_POINT"
# Verify copy integrity
du -b "$source" "$dest_path"
if sudo diff -qr "$source" "$dest_path"; then
echo "Verification successful: No differences found."
else
echo "Verification failed: Differences found!"
return 1
fi
}
# Function to format the drive
format_drive() {
local device="$1"
echo "Checking if device $device is mounted..."
safe_unmount "$device" || return 1
echo "Formatting $device..."
sudo mkfs.exfat "$device" && echo "Drive formatted successfully." || echo "Formatting failed."
}
# Function to display usage information
help() {
echo "Usage: $0 OPTION [ARGUMENTS]"
echo
echo "Options:"
echo " -c, -C DEVICE SOURCE_PATH Mount DEVICE and copy SOURCE_PATH to it."
echo " -l, -L List information about block devices."
echo " -f, -F DEVICE Format DEVICE."
echo
echo "Examples:"
echo " $0 -C /dev/sdx /path/to/data # Copy /path/to/data to /dev/sdx after mounting it."
echo " $0 -L # List all block devices."
echo " $0 -F /dev/sdx # Format /dev/sdx."
}
# Process command-line arguments
case "$1" in
-C | -c)
check_dependencies
ensure_mounted "$3"
copy_files "$2" "$MOUNT_POINT"
echo "Unmounting $MOUNT_POINT"
sudo umount "$MOUNT_POINT"
Hello everyone,
In Linux, files are permanently written only after the partition is unmounted. This might explain why many graphical tools deliver unsatisfactory performance when writing files to USB flash drives. To address this issue, I have developed a compact noscript which, thus far, has performed effectively.
Note: I was unable to get the status=progress feature to function correctly. However, the noscript successfully copies the transferred files to the USB flash drive. After conducting multiple tests, no errors were encountered.
#!/bin/bash
declare -r MOUNT_POINT="/media/flashdrive"
# Function to check for required commands
check_dependencies() {
local dependencies=(lsblk mkdir mount umount dd cp du grep diff)
for cmd in "${dependencies[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
echo "Error: Required command '$cmd' is not installed." >&2
exit 1
fi
done
}
# Function to check if device is mounted and unmount it
safe_unmount() {
local device="$1"
if mount | grep -qw "$device"; then
echo "$device is currently mounted, attempting to unmount..."
sudo umount "$device" && echo "$device unmounted successfully." || { echo "Failed to unmount $device."; return 1; }
fi
}
# Function to mount drive
ensure_mounted() {
local device="$1"
if ! mount | grep -q "$MOUNT_POINT"; then
echo "Mounting $device..."
sudo mkdir -p "$MOUNT_POINT"
sudo mount "$device" "$MOUNT_POINT" || { echo "Failed to mount $device."; exit 1; }
else
echo "Device is already mounted on $MOUNT_POINT."
fi
}
# Function to copy files or directories safely
copy_files() {
local source="$1"
local destination="$2"
local dest_path="$destination/$(basename "$source")"
if [[ -d "$source" ]]; then
echo "Copying directory $source to $destination using 'cp -r'..."
sudo cp -r "$source" "$dest_path" && echo "$source has been copied."
else
echo "Copying file $source to $destination using 'dd'..."
sudo dd if="$source" of="$dest_path" bs=4M status=progress && echo "$source has been copied."
fi
echo "Wait finishing changes..."
sudo mount -o remount,sync "$MOUNT_POINT"
# Verify copy integrity
du -b "$source" "$dest_path"
if sudo diff -qr "$source" "$dest_path"; then
echo "Verification successful: No differences found."
else
echo "Verification failed: Differences found!"
return 1
fi
}
# Function to format the drive
format_drive() {
local device="$1"
echo "Checking if device $device is mounted..."
safe_unmount "$device" || return 1
echo "Formatting $device..."
sudo mkfs.exfat "$device" && echo "Drive formatted successfully." || echo "Formatting failed."
}
# Function to display usage information
help() {
echo "Usage: $0 OPTION [ARGUMENTS]"
echo
echo "Options:"
echo " -c, -C DEVICE SOURCE_PATH Mount DEVICE and copy SOURCE_PATH to it."
echo " -l, -L List information about block devices."
echo " -f, -F DEVICE Format DEVICE."
echo
echo "Examples:"
echo " $0 -C /dev/sdx /path/to/data # Copy /path/to/data to /dev/sdx after mounting it."
echo " $0 -L # List all block devices."
echo " $0 -F /dev/sdx # Format /dev/sdx."
}
# Process command-line arguments
case "$1" in
-C | -c)
check_dependencies
ensure_mounted "$3"
copy_files "$2" "$MOUNT_POINT"
echo "Unmounting $MOUNT_POINT"
sudo umount "$MOUNT_POINT"
;;
-L | -l) lsblk -o NAME,MODEL,SERIAL,VENDOR,TRAN
;;
-F | -f)
check_dependencies
format_drive "$2"
;;
*)
help
;;
esac
​
https://redd.it/1cgpe1y
@r_bash
-L | -l) lsblk -o NAME,MODEL,SERIAL,VENDOR,TRAN
;;
-F | -f)
check_dependencies
format_drive "$2"
;;
*)
help
;;
esac
​
https://redd.it/1cgpe1y
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How do I get the number of processes spawned by a noscript?
TL;DR: What command will return a list or count of all commands spawned from the current noscript? Ideally it would include the actual commands running, eg:
​
I have a noscript that pulls data from multiple AWS accounts across multiple regions. I've implemented limited multi-threading but I'm not sure it's working exactly as intended. The part in question is intended to get a count of the number of processes spawned by the noscript:
Each AWS command takes a while to run, so I let it run 2 less than the number of cores in parallel. Here's an example of it and the rest of the code/logic:
​
list-ec2(){
local LPROFILE="$1"
local LREGION="$2"
[ $( jobs -r -p | wc -l ) -ge ${PARALLEL} ] && wait -n
aws ec2 describe-instances --profile ${LPROFILE} --region ${LREGION} > ${LOUTFILE} &
}
ACCOUNTS=( account1 account2 account3 account4 )
REGIONS=( us-east-1 us-east-2 us-west-1 us-west-2 )
PARALLEL=$(( $( nproc )-2 )) # number of cores - 2
for PROFILE in ${PROFILES@} ; do
for REGION in ${REGIONS@} ; do
list-ec2 "${PROFILE}" "${REGION}"
done
done
I have a handful of similar noscripts, some with multiple layers of functions and complexity. I've caught some of them spawning more than ${PARALLEL} number of commands so I know something's wrong.
I've also tried
Ideally I'd like a command that returns a list of all processes running within the current noscript including their command (eg: aws ec2 describe-instances ...) so I can filter out file-checks, jq commands, etc. OR - a better way of implementing controlled multi-threading in bash.
https://redd.it/1cgvc7v
@r_bash
TL;DR: What command will return a list or count of all commands spawned from the current noscript? Ideally it would include the actual commands running, eg:
aws ec2 describe-instances ...​
I have a noscript that pulls data from multiple AWS accounts across multiple regions. I've implemented limited multi-threading but I'm not sure it's working exactly as intended. The part in question is intended to get a count of the number of processes spawned by the noscript:
$( jobs -r -p | wc -l )jobs shows info on "processes spawned by the current shell" so I suspect it may not work in cases where a new shell is spawned, as in when using pipes. I'm also not sure if -r causes it to miss processes (aws-cli) waiting on a response from AWS.Each AWS command takes a while to run, so I let it run 2 less than the number of cores in parallel. Here's an example of it and the rest of the code/logic:
​
list-ec2(){
local LPROFILE="$1"
local LREGION="$2"
[ $( jobs -r -p | wc -l ) -ge ${PARALLEL} ] && wait -n
aws ec2 describe-instances --profile ${LPROFILE} --region ${LREGION} > ${LOUTFILE} &
}
ACCOUNTS=( account1 account2 account3 account4 )
REGIONS=( us-east-1 us-east-2 us-west-1 us-west-2 )
PARALLEL=$(( $( nproc )-2 )) # number of cores - 2
for PROFILE in ${PROFILES@} ; do
for REGION in ${REGIONS@} ; do
list-ec2 "${PROFILE}" "${REGION}"
done
done
I have a handful of similar noscripts, some with multiple layers of functions and complexity. I've caught some of them spawning more than ${PARALLEL} number of commands so I know something's wrong.
I've also tried
pgrep -P $$ but I'm not sure that's right either.Ideally I'd like a command that returns a list of all processes running within the current noscript including their command (eg: aws ec2 describe-instances ...) so I can filter out file-checks, jq commands, etc. OR - a better way of implementing controlled multi-threading in bash.
https://redd.it/1cgvc7v
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
What is the utility of adding 1>&2 if there isn’t file to redirect to?
https://redd.it/1cgxfac
@r_bash
https://redd.it/1cgxfac
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why does the order for redirection matter in bash?
For some reason, this works:
bash -i 1>& /dev/tcp/127.0.0.1/8080 0>&1 2>&1
However, this doesn't:
bash -i 0>& /dev/tcp/127.0.0.1/8080 1>&0 2>&0
I just inverted the order. Why doesn't it work?
I had this doubt years ago but it doesn't seem to leave my mind so here it is :).
https://redd.it/1ch2sg8
@r_bash
For some reason, this works:
bash -i 1>& /dev/tcp/127.0.0.1/8080 0>&1 2>&1
However, this doesn't:
bash -i 0>& /dev/tcp/127.0.0.1/8080 1>&0 2>&0
I just inverted the order. Why doesn't it work?
I had this doubt years ago but it doesn't seem to leave my mind so here it is :).
https://redd.it/1ch2sg8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Bash Fans: Tools for building a custom GPS? (Aware of GRASS, looking for guidance)
Hi!
As noscript implies — I’m wanting to build a custom GPS app using only low-level code (bash and C, specifically). My requirements are to:
- load a GPS map, doesn’t necessarily need more than terrain
- mark custom locations (ie “Mom’s House”, “Secret Smoke Spot”, etc)
- ability to set a waypoint and (ideally) get directions to said waypoint
Is this possible? I have seen grass, but want to know if there are any tools that are a bit more in tune with what I want. This project will be on a Raspberry Pi (and not the only code running), so it can’t take a whole lot of memory ideally.
Thanks in advance!
https://redd.it/1chabtu
@r_bash
Hi!
As noscript implies — I’m wanting to build a custom GPS app using only low-level code (bash and C, specifically). My requirements are to:
- load a GPS map, doesn’t necessarily need more than terrain
- mark custom locations (ie “Mom’s House”, “Secret Smoke Spot”, etc)
- ability to set a waypoint and (ideally) get directions to said waypoint
Is this possible? I have seen grass, but want to know if there are any tools that are a bit more in tune with what I want. This project will be on a Raspberry Pi (and not the only code running), so it can’t take a whole lot of memory ideally.
Thanks in advance!
https://redd.it/1chabtu
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
The REAL way to pipe stderr to a command.
( (seq 11 19; seq 21 29 >&2;) 2>&1 1>&11 11>&- | cat &> cat.txt 11>&- ) 11>&1
I just wanna document on the internet what's the real way to redirect stderr to a command, while still redirecting stdout to stdout, without the use of <(process) >(substitution).
I wanna document it because i just see people suggesting https://unix.stackexchange.com/questions/404286/communicate-backwards-in-a-pipe ways to get the job done but nobody ever mentions how to *just* pipe stderr to a command without side effects.
​
https://redd.it/1ch9rfn
@r_bash
( (seq 11 19; seq 21 29 >&2;) 2>&1 1>&11 11>&- | cat &> cat.txt 11>&- ) 11>&1
I just wanna document on the internet what's the real way to redirect stderr to a command, while still redirecting stdout to stdout, without the use of <(process) >(substitution).
I wanna document it because i just see people suggesting https://unix.stackexchange.com/questions/404286/communicate-backwards-in-a-pipe ways to get the job done but nobody ever mentions how to *just* pipe stderr to a command without side effects.
​
https://redd.it/1ch9rfn
@r_bash
Unix & Linux Stack Exchange
Communicate backwards in a pipe
I have a simple pipeline:
node foo.js | node bar.js
bar.js will read from stdin to get data from foo.js.
But what I want to do is ensure that bar.js gets one of the last messages from foo.js befo...
node foo.js | node bar.js
bar.js will read from stdin to get data from foo.js.
But what I want to do is ensure that bar.js gets one of the last messages from foo.js befo...
Handling special characters in paths when hard linking
Disclaimer: Completely new and mostly clueless about anything Linux related
I am using a python noscript to process some files and create some hard links of a large number of files. This might not be the most efficient but it works for my use case. My noscript compiles directory and file names into the hard link command ln {source} {dest} along with the respective mkdirs where needed. And what I do is execute it in the shell. I am running OMV 7.05, linux 6.1.0-20 kernel. I run and generate all link commands on my Win10 laptop and ssh into my omv machine to execute the commands.
Most of the link commands execute with no problem but when a filename contains a special character like quotes or exclamation marks, it does not work. Here is a sample command:
ln "/srv/dev-disk-by-uuid-5440592e-75e4-455f-a4b6-2f2019e562fa/Data/TorrentDownloads/TRAnime/Mr Magoo 2018/Mr Magoo S01 720p HMAX WEB-DL DD2.0 x265-OldT/Mr MagooS01E76Free the Rabbit!.nfo" "/srv/dev-disk-by-uuid-5440592e-75e4-455f-a4b6-2f2019e562fa/Data/Media/Anime/Mr Mgoo/Mr Magoo S01 720p HMAX WEB-DL DD2.0 x265-OldT/Mr MagooS01E76Free the Rabbit!.nfo"
it says `- bash: !.info not found`
I have tried escaping the special character like `Mr MagooS01E76Free the Rabbit\!.nfo` ***and*** `Mr MagooS01E76Free the Rabbit\\!.nfo (idk why but i just tried)` and it says
> ln: failed to access '/srv/dev-disk-by-uuid-5440592e-75e4-455f-a4b6-2f2019e562fa/Data/TorrentDownloads/TR\Anime/Mr Magoo 2018/Mr Magoo S01 720p HMAX WEB-DL DD2.0 x265-OldT/Mr Magoo_S01E76_Free the Rabbit\\!.nfo': No such file or directory
Ive also tried encasing just the filename or the word the
Same goes for single or double quotes, commas and iirc dashes too and this occurs irrespective of file type. The only way I got it to work is manually go in and removing the special character from the filename which is near impossible to do for hundreds of files.
Is there anyway I can make this work? I can adjust my noscript on my own but I just need a way to make the link command to work with the special chars.
https://redd.it/1chflwy
@r_bash
Disclaimer: Completely new and mostly clueless about anything Linux related
I am using a python noscript to process some files and create some hard links of a large number of files. This might not be the most efficient but it works for my use case. My noscript compiles directory and file names into the hard link command ln {source} {dest} along with the respective mkdirs where needed. And what I do is execute it in the shell. I am running OMV 7.05, linux 6.1.0-20 kernel. I run and generate all link commands on my Win10 laptop and ssh into my omv machine to execute the commands.
Most of the link commands execute with no problem but when a filename contains a special character like quotes or exclamation marks, it does not work. Here is a sample command:
ln "/srv/dev-disk-by-uuid-5440592e-75e4-455f-a4b6-2f2019e562fa/Data/TorrentDownloads/TRAnime/Mr Magoo 2018/Mr Magoo S01 720p HMAX WEB-DL DD2.0 x265-OldT/Mr MagooS01E76Free the Rabbit!.nfo" "/srv/dev-disk-by-uuid-5440592e-75e4-455f-a4b6-2f2019e562fa/Data/Media/Anime/Mr Mgoo/Mr Magoo S01 720p HMAX WEB-DL DD2.0 x265-OldT/Mr MagooS01E76Free the Rabbit!.nfo"
it says `- bash: !.info not found`
I have tried escaping the special character like `Mr MagooS01E76Free the Rabbit\!.nfo` ***and*** `Mr MagooS01E76Free the Rabbit\\!.nfo (idk why but i just tried)` and it says
> ln: failed to access '/srv/dev-disk-by-uuid-5440592e-75e4-455f-a4b6-2f2019e562fa/Data/TorrentDownloads/TR\Anime/Mr Magoo 2018/Mr Magoo S01 720p HMAX WEB-DL DD2.0 x265-OldT/Mr Magoo_S01E76_Free the Rabbit\\!.nfo': No such file or directory
Ive also tried encasing just the filename or the word the
Rabbit! in single quotes like ln "/srv/d....Mr Magoo_S01E76_Free the'Rabbit!'.nfo" ... with the same result.Same goes for single or double quotes, commas and iirc dashes too and this occurs irrespective of file type. The only way I got it to work is manually go in and removing the special character from the filename which is near impossible to do for hundreds of files.
Is there anyway I can make this work? I can adjust my noscript on my own but I just need a way to make the link command to work with the special chars.
https://redd.it/1chflwy
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community