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 3 years ago.
Improve this question
I need to be able to copy photos from a source folder into year folders based on the modification date of the file.
I am looking for a bash script on linux to do this
rsync wil not help you. You need bash and some linux commands:
Bash script:
file=myimage.jpeg
modtime=$(stat --printf=%Y $file)
year=$(date -d #$modtime +%Y)
mkdir -p "$year"
cp "$file" "$year"
Remarks
Rsync is good to copy files but not for the sorting task
The above example uses file modification time because file creation time is not available on some file systems
If you want to do the above for multiple files, use a bash for loop
Related
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
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 6 years ago.
Improve this question
I see these files many times when I use the command ls -a . But I want to open that file and access that file. What material contain that file. How it can be done ?
in linux all files whose name starts with . is hidden files.
these files are not shown when you use 'ls', but doing 'ls -a' shows these hidden files too.
if you execute ls -a on your home directory you will see lot of such files. (.profile .bashrc .history etc)
such filenames are given to config files. so most of these files will be in a text format..and may be in other format depending on to which application it belongs to.
to know the format use the following command file filename
to see text files cat filename
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 7 years ago.
Improve this question
I am using cp command in my program to make a copy of a text file. But when I use -p -i with cp I don't understand the difference between the both.
What's the difference between using simple cp and using options -p -i with it?
Here is my line code:
execl("/bin/cp","cp","-p","-i",argv[1],argv[2],NULL);
The -i stands for interactive mode, this will require input from the stdin before it will overwrite a file.
The -p (no capital p) will preserve mode ownership and timestamp. The latter one seems the more interesting one, this will actually cause a difference in your mss. When you're copying a file there is an owner of the file and there are different file permissions and a timestamp attached to it, if you want to keep these then use the -p parameter.
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 years ago.
Improve this question
I am writing a script that will move files from a local system to a remote system. It must do so through an encrypted channel like ssh. What is the best way to do this? I can perform this in two steps like:
scp *.jpg user#ip:
rm *.jpg
But, that is not an atomic process (like mv is for a local filesystem). If the copy fails I will no longer have the local copies either. How can I script this to make sure the local files only get removed if the copy succeeds?
You could use rsync with --remove-source-files:
rsync -avz --remove-source-files /local/dir/*.jpg user#ip:/remote/dir
An other solution, for launch in one time
scp /path/src/*.jpg user#host:/path/dst/ && rm /path/src/*.jpg
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
i am a linx beginner.the command options often confused me
e.g.
dash and double dash
let us look at 'man lftp'
mirror [OPTS] [source [target]]
-e, --delete delete files not present at remote site
--delete-first delete old files before transferring new ones
--depth-first descend into subdirectories before transferring files
what is -e?
-e ==? --delete
or
-e ==? --delete --delete-first --depth-first
-e is the same as --delete only.
There do not exist short options corresponding to --delete-first or --depth-first, so those have to be written out in full.