Usernames from other files
Say I had a text file of usernames and in another bash script I needed to use those usernames for it to advance how would I make that so it basically Denys access if the username is not in the other file
https://redd.it/17mttty
@r_bash
line counting plugin
Hey people,
I've created a plugin that I want to share with you.
Here's the link: https://github.com/Nelliguns/line-counter-tmux
The reason for creating this plugin is that I received the question of how many lines of code it took to create a specific project of mine where I then started going through the different files and roughly summing them in my head. Which then sparked the idea of making this plugin.
Give it a try and let me now what you think, happy to receive feedback and ideas of improvements.
Hope you like it :)
https://redd.it/17mcp7b
@r_bash
TIL bash -c takes up to 2 arguments
I expected bash -c 'echo "[$@]"' 10 20 30
to print 10 20 30 but surprisingly it only showed 20 30.
On the other hand bash -c 'echo "[$0 $@]"' 10 20 30
prints 10 20 30.
In man page I found this:
-c
If the -c option is present, then commands are read from the
first non-option argument commandstring. **If there are arguments after the commandstring, the first argument is assigned
to $0 and any remaining arguments are assigned to the positional parameters. The assignment to $0 sets the name of the
shell, which is used in warning and error messages.
Did you know this?
https://redd.it/17lxfr9
@r_bash
My Useful Shell Functions
https://muhammadraza.me/2023/shell-functions/
https://redd.it/17lt0vo
@r_bash
Minimalistic Bash script to fuzzy search and open chrome bookmarks from cli
Hello bash fellows,
I was a bit annoyed by reopening my frequently used bookmarks in Chrome. I added an extension called Quickmarks but don't like it that much. I want to be faster. And I want to have fuzzy search.
Hence, I decided to create a script that fetches all my bookmarks from the file system and opens a fuzzy search session on the bookmark titles. On selection, it opens the related url in Chrome.
https://preview.redd.it/b8lshwkl5pxb1.png?width=2002&format=png&auto=webp&s=f384841958dd466c45ac468c77d7707f30f2ff66
It works pretty well. What do you think? What is your workaround for this?
Link to the script 👉 https://github.com/fynnfluegge/mydotfiles/blob/main/.scripts/fzfbookmarks.sh
https://redd.it/17l7gzt
@r_bash
Sed scripting help
I want to modify paths explicitly written in files to remove one case of ../
For example:
Somedir/../../hw
Somedir/../../../sw
now becomes after using the sed
Somedir/../hw
Somedir/../../sw
I know for certain the ../ will be in between a known directory name (Somedir in this ex) and a folder with some name (hw and sw in this ex).
Please help anyone with this.
https://redd.it/17l3qjn
@r_bash
Custom waybar module for controlling gamma
Howdy folks! I'm very new to bash scripting and just wrote a couple scripts to control the temperature of my laptop's display from my bar. I wanted to put this somewhere in case it was useful to someone or there was a better way to do it. Right now there are a couple values that I want to be stored between instances of the scripts and I'm doing it in files. I wonder if there's a better way to do this that doesn't require the full absolute path of the files? Like if I can refer to the script's location in the file system?
Sorry if this question is super noobish, even a project this simple that's just a wrapper around someone else's code wasn't easy for me! So I appreciate any help I can get.
https://github.com/frolickingpotato/waybar-gammastep/blob/main/README.md
https://redd.it/17kqxsy
@r_bash
Need Help with Removing Files Using Bash Scriptif [[ $# -eq 0 ]]; then # if user doesn't enter anything, default to pwd
dir=$(pwd)
elif [[ -d "$1" ]]; then #if the user enters a directory that exists assign to dir
dir=$1
else
echo "usage: bash_file.sh <directory>" #otherwise, tell the user to enter a valid directory
exit 1 # exit program
fi
​for x in "$dir"/*; do #goes through and finds the files of size 0
if [[ -s "$x" ]]; then
rm "$x"
fi
done
For some reason, this removes the bash_file when I run bash_file itself.
I'm trying to remove files in a directory that have a size of zero. I'm not sure why it doesn't work properly.
https://redd.it/17kagkx
@r_bash
Create an If/Else Statement based on user input
I'm trying to add a portion to a script I'm making to just verify if something is installed, in this case I just want to verify if Flatpak is already installed on the computer, and if not, give the user the option to install Flatpak if they want to or not.
This is what I have so far but I'm unsure what command to use for user input. I did some Googling and found that the read
command might work, but when I look up the man page on it on my machine, it looks different than what i'm seeing on sites like stackoverflow or AskUbuntu:
dpkg -s "flatpak" &> /dev/null
if $? -ne 0
then
echo "Flatpak is not currently installed on your system."
echo "Would you like to install Flatpak? (y,n): "
NOT SURE WHAT TO PUT HERE
else
echo "Flatpak is installed. Starting download shortly. . ."
fi
https://redd.it/17k1yg2
@r_bash
Split string to an array with IFS by linebreak
Hello,
I am struggling with a simple task. I'm coming from python and decided to write a script with bash. For now I regret this, but try to accomplish it to learn. With python I would have finish this hours ago.
Here is the problem: I want to covert to following string to an iteratable array:
[ "Hello, hello1", "World", "How", "Are", "You" ]
the_string=$(echo $the_string | tr -d '[' | tr -d ']' | sed 's/\", \"/"\\n"/g')
"Hello, hello1"
"World"
"How"
"Are"
"You"
IFS=$'\n' read -r -a string_array <<< "$the_string"
Can someone help me with a task?
I am using Kali VM and i need to write a BASH script that will scan my VMware NAT network via ARP, collect those “live” IPs, place the IPs into a file, then run the following scans based on those “Live” IPs.
https://redd.it/17iwctu
@r_bash
Daily note script
Under the ~/Desktop/Journal/
I have my journal pages, e.g 28-10-23
.
I tried to write a script that would compare the current date with the file name under that directory.
If there's no file with the current date, it would create it, if there is, then it would sleep until there isn't.
The script goes like this:
d=$(date "+%d-%m-%y")
f=$(ls $HOME/Desktop/Journal | grep $d)
while true;
do
while [ "$d" == "$f" ];
do
sleep 1
done
touch $HOME/Desktop/Journal/$d
done
If the file is already there and I run the script, then it just sleeps, but if it isn't, then it creates it as well as doesn't go into the nested while loop for sleep, meaning it keeps creating it.
I don't understand why it doesn't go into the nested while loop for sleep when the file is created, but doesn't created it while in the nested while loop sleeping.
https://redd.it/17iltpo
@r_bash
Why is my terminal not redrawing the screen when I reach two lines of input?
https://imgur.com/a/hIsrUSy
Kitty is shown in the GIFs, but it just mirrors the output from bash. Here is entirety of my .bashrc configuration:export PS1="\e[34m\]
∴ \e[32m\]
\\u\e[31m\]
\-> \e[33m\]
\\W \e[37m\]$ "
Commenting out the entire line doesn't fix the issue. Entering and exiting full-screen will properly refresh bash.
https://redd.it/17i3asu
@r_bash
Flushing the read buffer, or something similar
Howdy, I've a tiny script which i've just updated to use inotifywait to block until a file is opened or closed, replacing a dumb periodic poll. Nice, like that. But the file is opened and closed a few times when it does, meaning when the access happens, the loop is executed (differently) a few times in a second or so. Is there any way I can purge the pending reads, and instead wait for a few seconds to let things settle and then see what's what?
inotifywait /dev/video? -e open,close -m | while read LINE
do
sleep 2 # wait for steady state
do_something_to_clear_any_backlog
lsof /dev/video? 2>&1 | grep -q zoom \
&& echo -e "\xA0\x01\x01\xA2" \
|| echo -e "\xA0\x01\x00\xA1"
done > /dev/ttyUSB1
TBH I guess I could just NOT use the -m and restart inotifywait each loop, but I'm mostly curious to know if there's a good solution this way.
\[BTW, as I think it's funny, this is a script that "puts on a red light" in another room when I'm on a zoom video call to stop my kids bugging me when I can't reply... so I called it "[roxanne.sh](https://roxanne.sh)" :D \]
https://redd.it/17hipg3
@r_bash
cURL: Need to make host server think I am a browser and not cURL.
I found a website that posts stats every month that are useful to my business. They post them for free.
The link to download a csv file, which is the format I need, looks like an API call:
https://gs.statcounter.com/os-market-share/tablet/chart.php?device=Tablet&devicehidden=tablet&statTypehidden=oscombined®ionhidden=ZA&granularity=monthly&statType=Operating%20System®ion=South%20Africa&fromInt=202209&toInt=202309&fromMonthYear=2022-09&toMonthYear=2023-09&csv=1
The problem I have, is if I paste that link in any browser, I get a CSV download. If I access it with wget or curl, I get a bit of useless XML data.
I suspect they are detecting client type to stop people doing this.
I simply want to write a script that pulls down certain datasets, then processes that so I can store the final data in a specific folder on my Nextcloud server. I want to use it for internal use (decision-making), but I want the data to be updated each month automatically, rather than me sit and manually download it each month.
I know cURL is super powerful and flexible, so can someone explain to me how I would get cURL to tell the host server that it is Firefox or Chrome or whatever?
Edit:
The problem I had was caused by a really stupid but easy to make mistake.
I ran the following:
curl https://gs.statcounter.com/os-market-share/tablet/chart.php?device=Tablet&devicehidden=tablet&statTypehidden=oscombined®ionhidden=ZA&granularity=monthly&statType=Operating%20System®ion=South%20Africa&fromInt=202209&toInt=202309&fromMonthYear=2022-09&toMonthYear=2023-09&csv=1
That output the following:
1 11976
2 11977
3 11978
4 11979
5 11980
6 11981
7 11982
8 11983
9 11984
10 11985
11 11986
2 Done devicehidden=tablet
[3] Done statTypehidden=oscombined
[4] Done regionhidden=ZA
5 Done granularity=monthly
6 Done statType=Operating%20System
7 Done region=South%20Africa
8 Done fromInt=202209
9 Done toInt=202309
10- Done fromMonthYear=2022-09
<chart caption='StatCounter Global Stats' subCaption="Top 5 Desktop Browsers in from - , 1 Jan 1970" anchorAlpha='100' showValues='0' bgColor='FFFFFF' showalternatevgridcolor='0' showalternatehgridcolor='0' bgAlpha='0,0' numberSuffix='%' canvasBorderAlpha='50' bgImage='https://www.statcounter.com/images/logogschartfadedpadded.png' bgImageDisplayMode='fit' canvasBgAlpha='0'
exportEnabled='1' exportAtClient='0' exportAction='download' exportFormats='PNG' exportHandler='https://gs.statcounter.com/export/index.php' exportFileName='StatCounter-browser--all--'
legendBorderAlpha='0' legendBgColor='000000' legendBgAlpha='0' legendPosition='RIGHT' legendShadow='0'
canvasBorderThickness='1' canvasPadding='0' showBorder='0' labelDisplay='Rotate' slantLabels='1'><categories></categories><styles>
<definition>
<style name='myCaptionFont' type='font' size='14' bold='1' isHTML='1' topMargin='14' />
</definition>
<application>
<apply toObject='Caption' styles='myCaptionFont' />
</application>
<definition>
<style name='myLegendFont' type='font' size='11' color='000000' bold='0' isHTML='1' />
</definition>
<application>
<apply toObject='Legend' styles='myLegendFont' />
</application>
<definition>
<style name='myHTMLFont' type='font' isHTML='1' />
</definition>
<application>
<apply toObject='TOOLTIP' styles='myHTMLFont' />
</application>
</styles>
</chart>
I forgot to put quotes around the url.
I do this:
curl
Veriphone API for Laravel applications.
Veriphone API is a REST based JSON API. It provides a set of stateless endpoints that any program or web browser can call by sending a standard HTTP request. Veriphone will respond with a standard HTTP response carrying a JSON payload. This documentation describes these endpoints, their input/output parameters and authentication methods.
​
https://github.com/slvler/veriphone-service
https://redd.it/17mhvhb
@r_bash
Troubles when quoting grep statement for array
Hey all!
The idea is to get an array of space-separated colors from a global config file. This works but shellcheck keeps complaining about the $1 var not being quoted. However when I single quote it the variable isn't expanded.read -ra hexCols <<< "$(grep ^$1 $mainConf | cut -d: -f2 | xargs)"
I'm sure I'm missing something obvious but as I'm quite new to this I'm struggling to see what.
I hope someone can help!
https://redd.it/17m9bjb
@r_bash
unexpected bash code behavior: won't total up numbers
I'm having trouble understanding why the bash program exits when the user enters integers.
total=0 # keeps track of the running total
# while the number of arguments isn't zero
# and the argument is an integer,
# add to the integer to the running total
# move to the next argument and check
# it against the req's (i.e. integer?)
while [ $# -gt 0 && $1 =~ ^-?[0-9+$ ]]; do
total=$((total + $1))
shift
done
# if the user entered something other than an
# integer or entered nothing at all
# display the error message "this program...."
if ! [ $1 =~ ^-?[0-9+$]]; then
echo "program only accepts integers"
echo "usage: $0 integer 1 integer 2 ... integer x"
exit
fi
# lastly, display the total
echo $total
I can't spot the error...
https://redd.it/17lsfnf
@r_bash
Script doesnt fully work
Hello guys
So because of the recent decision of youtube making people not be able to watch ad-free videos with adblocker extension, I wanted to create an script so that I can watch videos with mpv. The issue I have with mpv is that the it doesnt buffer fast enough for me. So I wanted to combine yt-dlp with mpv.
Now my script is ready but it has an issue. It works when I run each command from the script on my own with the terminal. But when running the script via bash y.bash, it doesnt perform the last command.
This is my script:
url=$(xsel -bo)
filename=$(shuf -i 1-10000000 -n 1)
fileextension="webm"
yt-dlp -o - "$url" | mpv --input-ipc-server=/tmp/mpvsocket - &
yt-dlp -o "/home/reddituser/Downloads/yt-dlp/$filename.$fileextension" "$url" && fullname="/home/reddituser/Downloads/yt-dlp/${filename}.${fileextension}"
timestamp=\"$(echo '{ "command": "get_property", "time-pos" }' | socat - /tmp/mpvsocket | jq -r '.data' | awk '{printf "%.6f\n", $1}')\"
echo $timestamp
echo '{ "command": "loadfile", "'"$fullname"'" }' | socat - /tmp/mpvsocket
echo "{ \"command\": \"set\", \"time-pos\", $timestamp }" | socat - /tmp/mpvsocket
The is the last command, that doesnt work
echo "{ \"command\": \"set\", \"time-pos\", $timestamp }" | socat - /tmp/mpvsocket
This is how the script works:
1. variable "$url" is set to the value of clipboard
2. generate random filename
3. set webm as file extension
4. download (from $url) temporarily a 720p video with yt-dlp and directly pipe it to mpv, mpv directly plays the 720p video, also uses IPC so that I can get some values, make it run in the background with "&"
5. Download a high quality version (from $url), and save it to my location with the filename being $filename.$fileextension, wait until done and then set the variable $fullname for the fullpath&fullname
6. Value of $timestamp equals the current timestamp of the 720p video playing, example \\"RANDOM_FLOATIANG_POINT\\" or \\"23.23953\\"
7. Yes It needs to be escaped with \\"
8. replace the current 720p video playing with the new high resolution downloaded video
9. Set the timestamp for the high resolution video to the one of 720p had right before it got replaced
Now the issue is command 9 doesnt work.
I get this error: {"request_id":0,"error":"error running command"}
The reason for this script is to directly watch the youtube video and replace it as soon as possible with a high resolution one that got downloaded, this way I can seek very fast without buffering and I am not anymore reliant on youtube.
​
https://redd.it/17lr9m5
@r_bash
Sed How to uncomment two lines in a file
Let's say I have a very long configuration file, and in it there's the following lines:
/etc/animals.conf
-----------------
#[cats]
#Include = /etc/cats.d/listofcats
/etc/animals.conf
-----------------
[cats]
Include = /etc/cats.d/listofcats
Help creating shell script for removing embedded subtitles from video files
I have a series of video lessons and part of the software leverages an AI assistant to automatically create and embed subtitles to the spoken parts. These subtitles are not captured and translated perfectly, so I'd like to be able to proofread and update these text files manually.
I have a file (queue.txt) where I list the full path to the video file, such as this:
/Volumes/Lessons/101/lesson1.mkv
/Volumes/Lessons/101/lesson2.mkv
/Volumes/Lessons/101/lesson3.mkv
I'd like to be able to run a shell script which takes this list of files and runs the following command against it:
mkvmerge -o <outputfilename> -S <inputfilepath>
The hope is that it outputs the following files in my current directory like this:
lesson1.mkv
lesson2.mkv
lesson3.mkv
Thanks so much in advance. This is not my area of expertise but I have a very large number of video lessons that I'm trying to make available for these students and ensure that subtitles are available for accessibility reasons.
https://redd.it/17krvyj
@r_bash
Minimalistic Bash script to fuzzy search and open chrome bookmarks from cli
Hello bash fellows,
I was a bit annoyed by reopening my frequently used bookmarks in Chrome. I added an extension called Quickmarks but don't like it that much. I want to be faster. And I want to have fuzzy search.
Hence, I decided to create a script that fetches all my bookmarks from the file system and opens a fuzzy search session on the bookmark titles. On selection, it opens the related url in Chrome.
https://preview.redd.it/27veeg13pixb1.png?width=2002&format=png&auto=webp&s=01c3597ecbb7e8a981fae8723c44c9250fc2a600
It works pretty well. What do you think? What is your workaround for this?
Link to the script 👉 https://github.com/fynnfluegge/mydotfiles/blob/main/.scripts/fzfbookmarks.sh
https://redd.it/17ki4lp
@r_bash
JQ - filter datasets in array based on index value within each dataset of array.
I have a very large JSON file.
Inside that JSON file I am only interested in the data that exists with a certain value in one of the indexes within that array.
I am trying to figure out how to use JQ to export the complete datasets where object_type="deckCard"
in each dataset of the array.
Example output desired:
{
"id": "651",
"parent_id": "0",
"topmost_parent_id": "0",
"children_count": "0",
"actor_type": "users",
"actor_id": "alec",
"message": "Please advise on whether I may need to edit down these bios.",
"verb": "comment",
"creation_timestamp": "2023-10-11 12:52:56",
"latest_child_timestamp": null,
"object_type": "deckCard",
"object_id": "77",
"reference_id": null,
"reactions": null,
"expire_date": null
},
{
"id": "652",
"parent_id": "0",
"topmost_parent_id": "0",
"children_count": "0",
"actor_type": "users",
"actor_id": "alec",
"message": "There images have been attached to this card.",
"verb": "comment",
"creation_timestamp": "2023-10-11 12:53:15",
"latest_child_timestamp": null,
"object_type": "deckCard",
"object_id": "77",
"reference_id": null,
"reactions": null,
"expire_date": null
}
​
https://redd.it/17kf8mk
@r_bash
how do i fix command nit found error after running script
https://redd.it/17jvmld
@r_bash
Need help - (List the folders that contain the specified file and select from the list and move)
Hi,
I'm new to bash scripting, just starting to automate my linux journey. :)
I've been trying to find solutions to this, without any luck.
​
What the script should do:
\- cd to the main folder (Application)
\- Find which profile folders contain a specific file (File_X) and list them
\- The selection is made with a number, after which the script will move to that folder.
​
File structure:
/Application/profile 1/File_X
/Application/profile 2/
/Application/profile 3/File_X
/Application/profile 4/File_X
​
"These profile folders contain the necessary file you want to update:"
1. profile 1
2. profile 3
3. profile 4
"Give number to select" -> 2
\-> move to that selected folder -> profile 3
​
I hope my explanation is clear on some level. If you have a solution to this, I'd love to see it in the answers. If possible, could you also explain a bit what the different commands do. Like I said, I don't have much experience. However, I don't just want to copy/paste finished code, I also want to learn at the same time.
​
https://redd.it/17iyx9p
@r_bash
Trouble making shortcut for CUDA_VISIBLE_DEVICES=
Hi, I got tired of typing `CUDA_VISIBLE_DEVICES=` so in my .bashrc, I put: `export cuda="CUDA_VISIBLE_DEVICES"`. but it keeps giving me the error below for some reason. why is this so? i thought creating a variable would work.
$ time $cuda=3 python inference.py
-bash: CUDA_VISIBLE_DEVICES=3: command not found
chatGPT suggested:
function set_cuda() {
export CUDA_VISIBLE_DEVICES=$1
}
which i guess works, but aesthetically, something close to `cuda=3` would be rly nice haha
​
edit: welp I tried `set_cuda 3` and:
Traceback (most recent call last):
File "/netmnt/vast01/cbb01/lulab/andrew/similar_articles/baselines/inference.py", line 147, in <module>
run(args)
File "/netmnt/vast01/cbb01/lulab/andrew/similar_articles/baselines/inference.py", line 83, in run
model.to(args.device)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2014, in to
return super().to(*args, **kwargs)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1145, in to
return self._apply(convert)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/torch/nn/modules/module.py", line 797, in _apply
module._apply(fn)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/torch/nn/modules/module.py", line 797, in _apply
module._apply(fn)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/torch/nn/modules/module.py", line 797, in _apply
module._apply(fn)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/torch/nn/modules/module.py", line 820, in _apply
param_applied = fn(param)
File "/netmnt/vast01/cbb01/lulab/andrew/modern/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1143, in convert
return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
RuntimeError: CUDA error: out of memory
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
​
https://redd.it/17irid3
@r_bash
shell script to control spotify
https://github.com/umtksa/spoty
I'm using my old computer to run daily apps over the corner while I'm working like playing music from spotify, watching a folder to print every pdf file created inside a dropbox folder
this is the script I use over ssh to make my life easier
with this script I can play a spesific playlist
play/pause music
play next song
control volume with an integer
https://redd.it/17igwap
@r_bash
is there any way I can only parse a single command line argument without bothering with others
I have a command that I want to wrap, it doesn't take an argument for output file but I want to wrap it in a function to achieve that, I'm trying to use `getopt` and `getopts` and both require that I know all the arguments I'm going to give to the command beforehand. for example: I have a function like this
wrapper_command () {
echo $(getopt "o:")
while getopts "o:" opt; do
case "${opt}" in
o) output=$OPTARG;;
esac
done
my_command $* > $output
}
then I invoke the command using `wrapper_command <args> -o outputfile` but `getopts` returns `--` for the output and `getopts` complains when the other arguments are not included in the optstring.
https://redd.it/17ht40g
@r_bash
"https://gs.statcounter.com/os-market-share/tablet/chart.php?device=Tablet&devicehidden=tablet&statTypehidden=oscombined®ionhidden=ZA&granularity=monthly&statType=Operating%20System®ion=South%20Africa&fromInt=202209&toInt=202309&fromMonthYear=2022-09&toMonthYear=2023-09&csv=1"
and then I get this:
"Date","Android","iOS","Unknown","Windows","Linux","Other"
2022-09,61.01,38.46,0.33,0.18,0.01,0
2022-10,59.53,40.21,0.15,0.09,0.02,0.01
2022-11,60.19,39.64,0.1,0.06,0.01,0
2022-12,59.12,40.73,0.1,0.04,0.01,0
2023-01,56.26,43.52,0.16,0.05,0.01,0
2023-02,57.23,42.55,0.12,0.08,0.01,0
2023-03,58.79,41.02,0.16,0,0.02,0
2023-04,58.72,40.99,0.28,0,0.02,0
2023-05,56.79,42.68,0.48,0,0.04,0
2023-06,60.21,39.1,0.67,0,0.02,0
2023-07,60.21,39.07,0.62,0,0.09,0
2023-08,60.1,39.14,0.72,0,0.03,0
2023-09,59.13,39.94,0.9,0,0.03,0.01
The lesson here is always use quotes. Make it a habit, or special characters will make things frustrating...
https://redd.it/17h2xpp
@r_bash
Copy and rename file from shell script
This is a pretty basic question but I’ve been struggling getting this working for some reason. I am trying to copy a file from one directory to another and renaming it along with the copy. This is being done inside of a shell script, and I have a variable called $filename that stores the NEW file name. Here is the code snippet:
filename="IRcamfpgacksm${checksum}ver${version}.pdb"
#filename="Thisisafile.txt"
echo "filename: ${filename}"
cp ./par/ircamfpga/designer/impl1/*.pdb output/pl/$filename
The output of the echo command on the console is:
.pdbname: IRcamfpgacksmA415ver0x0081
But the file that gets copied to the new directory does not have the correct name. When I use the version of $filename that is commented out, it works perfectly fine.
https://redd.it/17gylgx
@r_bash