Renaming file with date using mv command [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 months ago.
Improve this question
How to change the filename from file.txt to renaming it to be file_may_20_2020.txt
using mv command?
I have used
mv file file_(`date`).txt
I still don't know how to put a command inside another command

Use either
mv file file_"`date +"%B_%d_%y"`".txt
or
mv file file_"$(date +"%B_%d_%y")".txt

mv file file_"$(date +"%B_%d_%y")".txt
What you put inside the $ is like a template string and its value is placed in the string

Related

How do I remove a directory with the name of '--' [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
A badly-written script created a directory named '--' (including the single quotes) in my home directory.
When I cd to that directory, I am brought back to my home directory.
I'd like to remove that item, but cannot figure out how to do it. Escaping some or all of the characters in the directory name, returns No such file or directory.
rmdir \'--\' should do the trick
simply type the following:
rm -rf \'--

How to extract the file with same name from different directories in linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have lots of folders with the same file name, like:
fd1/01.wh.txt
ff2/01.wh.txt
fk2/01.wh.txt
fd3/01.wh.txt
I want to extract 01.wh.txt from these different directories, and get a new folder including all 01.wh.txt with the specific parent code:
new_folder/
fd1.01.wh.txt
ff2.01.wh.txt
fk2.01.wh.txt
fd3.01.wh.txt
How to execute the code in the Linux system?
Try this..
for i in find . -name "*.txt"; do echo $i; fname=echo $i|sed 's/\//-/g'; echo $fname; cp $i ./newdir/$fname; done

Unix rename command for one character on filename [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have over 1,000 files that I will like to change one character on the filename, Ex: GM001001, GM001002, GM001003, etc.. to be rename to GX001001, GX001002, GX001003, etc... As you can see the common denominator will be the M to be replace for an X.
You can combine mv with string replace to achieve this:
for f in $(ls)
do
mv $f ${f/GM/GX}
done

how to rename files and thank you [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
how I can rename several files (Q0138-9061933666_S5.fasta.db) in a folder and leave only the no as ca (Q0138-9061933666_S5.db) i.e. delete .fasta from all files
Assuming you are in the folder where the files are placed.
for i in *.fasta.db
do
mv $i ${i/\.fasta/} # remove "fasta" from file name
done
See Replace one substring for another string in shell script for details about string substitution

Alias in bash not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
alias bp="cat $# > $#.BACK"
My second idea was:
alias bp="cp $#{,.BACK}"
So i want to have a command to backup a file.
It does not raise any error but it simply doesn't work.
Aliases are purely a textual replacement. If you want to use or manipulate the arguments, you need to create a function:
bp () {
for file; do
cp -i "$file" "$file".BACK
done
}

Resources