How to rename files in Linux like the ren command in Windows

How to rename files in Linux like the ren command in Windows I need to rename a bunch of files (more than 100) on an Ubuntu system, and want to know how to I do that when the pattern of the files is something like "Filename_01.jpg" to "NameOfFile_01.jpg" In Windows, I would type: ren Filename_*.jpg …

Total answers: 1

how to write function with nested commands

how to write function with nested commands I’m trying to write a find and cd function like so: findcd () { cd "$(dirname "$(find ‘$1’ -type ‘$2’ -name ‘$3′)")" } to be called like so: find . f [FILE_NAME] But it’s seeing the dollar sign and expecting more arguments as oppose to executing what’s inside. …

Total answers: 1

How to subtract column values by the first row with awk?

How to subtract column values by the first row with awk? The input file is lines of "id number1 number2 count", both number1 and number2 are ascendant. Barcode000000 48521 1855 0 Barcode000001 48621 1855 0 Barcode000002 48721 1855 1 Barcode000003 48821 1855 0 Barcode000004 48921 1955 20 Barcode000005 49021 1955 0 Now I use awk …

Total answers: 3

How can play mp3 and its LRC file together?

How can play mp3 and its LRC file together? ls music song.lrc song.mp3 song.lrc is the song lyrics of song.mp3,how can play song.mp3 and song.lrc together?Listen to the music and watch the lyrics?I have tried with vlc,smplayer,audacious,clementine;all of them can play music ,not showing lyrics. The song.lrc is in the below format: [00:12.00]Line 1 lyrics …

Total answers: 1

How can I pass $@ to exec.args of Maven?

How can I pass $@ to exec.args of Maven? things I tried in my script run.sh: mvn exec:java -Dexec.mainClass=my.App -Dexec.args="$@" mvn exec:java -Dexec.mainClass=my.App -Dexec.args=$@ when I call the script like: ./run.sh arg1 arg2 arg3 the arguments are not passed to Java application. instead Maven tries to interpret them as if they were maven options. EDIT: …

Total answers: 1

Can I disable password login but still allow sudo?

Can I disable password login but still allow sudo? While answering comments I realized what I should really be asking, so I asked a new question. I’m on a Raspberry Pi, but I don’t think this question is specific to Raspberry Pi OS. I only use an SSH key to log in as user pi. …

Total answers: 1

perl: replace a string with variable containing new lines (line breaks)

perl: replace a string with variable containing new lines (line breaks) I want to make edits containing meta characters. Here https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed one of solutions is via perl with sQ … E (near end of accepted answer). It is mentioned it handles multi-liners, but: echo ‘a-b’ > a.txt;from=’-‘;to=’n’;perl -s -0777 -pe ‘s/Q$fromE/$to/’ — -from="$from" -to="$to" a.txt …

Total answers: 2

Onedrive sync folders and files without downloading them in Ubuntu 23.04

Onedrive sync folders and files without downloading them in Ubuntu 23.04 After a few years I have installed Ubuntu again and I’m trying to configure it to my liking. I own a Microsoft account with 1 TB cloud storage. I’ve installed the Onedrive client on Ubuntu but it seems that it downloads all the files …

Total answers: 1

Unable to pass AWS CLI commands in double quotes in json syntax

Unable to pass AWS CLI commands in double quotes in json syntax I’m working with the below script,getting syntax error as unable to fetch credentials from secrets manager. "username":"AWS CLI command of access Key i have entered", "password":"AWS CLI command of secret key i have entered". Great if anyone can help #!/bin/bash # Send the …

Total answers: 2

How to Make a Systemd Private Network Namespace Accessable

How to Make a Systemd Private Network Namespace Accessable So I have an application that only binds to 0.0.0.0 and listens on a port (TCP). The communication is unencrypted and unauthorized so I’d like to work around that without getting too deep into the weeds. I’d like it to bind on 127.0.0.1 so I can …

Total answers: 1

How (abc) is parsed in bash

How (abc) is parsed in bash I’m using a program designed for windows that I compiled myself for GNU/linux. The program works in the command line, and one argument looks like this: prgm -arg1 abcd(10)(22) -i files.ext Where (10) and (22) are flags like a, b, c and d. This command is failing because bash …

Total answers: 2

Replace last nonblank line with a command output

Replace last nonblank line with a command output I have a .env file like PARAM1=val PARAM2=val I want to replace the last noblank line with another file content So far I have something like below: { (sed -e :a -e ‘/^n*$/{$d;N;ba’ -e ‘}’ local.env | sed ‘$d’ local.env && printf "CONFIG=%s" "$(cat config.json | jq …

Total answers: 2

renaming files based on matched pattern in another file

renaming files based on matched pattern in another file I have a list of files: out_CCGCGGTT+CTAGCGCT_R1.fq.gz out_TTATAACC+TCGATATC_R2.fq.gz out_GGACTTGG+CGTCTGCG_R1.fq.gz out_AAGTCCAA+TACTCATA_R2.fq.gz … the adaptor IDs (between the two underscores, like AACGTTCC+AGTACTCC, AACGTTCC+AGTACTCC) match with the first column of ID.file.txt head ID.file.txt: CCGCGGTT+CTAGCGCT NHL_332_N TTATAACC+TCGATATC NHL_333_T GGACTTGG+CGTCTGCG NHL_334_T AAGTCCAA+TACTCATA NHL_335_T ATCCACTG+ACGCACCT NHL_336_N GCTTGTCA+GTATGTTC NHL_337_N CAAGCTAG+CGCTATGT NHL_338_N TGGATCGA+TATCGCAC NHL_339_T …

Total answers: 2

How to find a string in files, said string including line breaks, ", @

How to find a string in files, said string including line breaks, ", @ I know grep allows me to search for a string in files, however I did not manage to find the right method to search for the following string: "snapshot3" : { "@custom_name" : true So the string I am looking for …

Total answers: 1

How can I write my input down to file?

How can I write my input down to file? Recently, I needed to write my terminal output down. And I’ve read this question to find the answer. But now, I would like to write my commands down (which I type in terminal, for example:sudo apt update etc.) to store the history of what I have …

Total answers: 1

With what shared objects are the debug symbols in a debug deb package assocciated with?

With what shared objects are the debug symbols in a debug deb package assocciated with? I am trying to find debug symbols that are associated with various shared objects shipped under the Ubuntu 22.04 distro. For example, let’s consider the amd64 deb package: libssl3 (version 3.0.2-0ubuntu1) which ships a number of stripped shared objects. One …

Total answers: 1