Move all files whose names contain a capital letter from source directory to target directory? [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 7 years ago.
Improve this question
How to write this linux command?
Move all files whose names contain a capital letter from source directory to target directory?

If I read your question correctly, use this:
mv src/*[A-Z]* target/

The obvious but wrong solution is
mv src/*[A-Z]* dest
However, the order of letters is locale dependent. [A-Z] therefore can contain lower case letters:
$> touch abc aBc
$> export LC_ALL=C
$> ls *[A-Z]*
abc
$> LC_ALL=en_US
$> ls *[A-Z]*
aBc abc
so make sure to set LC_ALL properly.
export LC_ALL=C
mv src/*[A-Z]* dest
BTW: *[A-Z]* is evaluated by the shell, not mv. Therefore the following does not work:
LC_ALL=C mv rc/*[A-Z]* dest ## does not work

This version ensure that only "Files" in root source folder are moved to target directory:
find /source/*[A-Z]* -maxdepth 1 -type f -exec mv {} /target \;

Related

Rich globbing `ls [G-S]*` in fish shell? [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 5 years ago.
Improve this question
In Bash it is possible to
ls [G-S]*
and it would list all files from g-s and G-S.
How is that done in Fish shell?
Fish currently does not support a rich glob syntax. The current thinking is that a glob command should be added in keeping with the fish goal of doing things via commands rather than magic syntax. See, for example, https://github.com/fish-shell/fish-shell/issues/3681. The solution is to create a function that filters the results. For example, the ** glob matches all files and directories in and below the CWD. I frequently want just the plain files and want to ignore the .git subdir. So I wrote this function:
function ff --description 'Like ** but only returns plain files.'
# This also ignores .git directories.
find . \( -name .git -type d -prune \) -o -type f | sed -n -e '/\/\.git$/n' -e 's/^\.\///p'
end
Which I can then use like this: grep something (ff). You could create a similar function that uses the find -name pattern matching feature or filter the results with string match --regex.
You can use find -iregex "./[G-S].*". Fish is quite limited in this regard.

How to search for a string in entire linux system? [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 7 years ago.
Improve this question
I am looking to search for a string for example "/uniquexx" in the entire hard drive and find the files where it is referenced? How could I do that? I tried grep and find / but no luck
grep -r blablastring /
-r means recursive searching from all subdirectories.
If you want to search only text files, try ack. It's like grep, but defaults to skipping file types it recognizes as binary. It also highlights matches by default, when searching recursively in a directory.
Some answer point with use of grep.
What this actually does is make a list of every file on the system, and then for each file, execute grep with the given arguments and the name of each file
use
find / -xdev '(' -type f -a -name '*.txt' -a -size -2M -a -mtime -5 ')' -print0 | xargs -0 grep -H "800x600"
read more: How to search text throughout entire file system?
You can try:
grep -r -H "your string" /home/yourdir
-H means you will shown the filename contains your string.
Anyway if you want to search within the WHOLE linux directory, you need sudo privileges.

Linux/Unix Command Needed for finding files on a particular date [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
I need help finding files in a directory which contain a word/string and on a particular date.
Currently I am using this command:
find . -exec grep -l .string. {} \;
This command returns all the files containing that string in that directory. I would like to get those files on from a particular date, for example 12/24/2013.
You can use:
find . -type f -exec grep 'string' {} \; -exec ls -l {} \; | grep 'Dec 24'
Which will search any files which contain the string string, and then execute ls -l on only those files, and finally, grep out any that match Dec 24.
This works because find will apply it's arguments in order, so only those that match previous results will be passed on.
Maybe this could help you with grep:
find /path/to/find -type d -atime -7
The last parameter is days here 7 days before you can modify to particular dat ,atime is the file access time ,'d' is directory search for directory for find a file replace 'd' with 'f' give the path where to find and then finally make pipeline this with grep to string to search

What is the linux command to give execution permission of all files in current folder [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
Remember I need the command to change permissions of all files in current folder?
It depends on what you mean by "current" folder; if you mean the current folder (and all subfolders) then you could use find and chmod like so -
find . -type 'f' -exec chmod +x {} \;
If you mean the current folder (and no sub-folders) then you would use it like so -
find . -maxdepth 1 -type 'f' -exec chmod +x {} \;
OR you could use find (possibly with maxdepth) and xargs likes so
find . -print0 | xargs -0 chmod +x
Note that these commands will correctly handle files with spaces in the name and most other edge cases.
Use chmod with a glob:
chmod +x *
(Technically that will give permission to list directories, too, but that shouldn't be a problem.)

how to remove a file named "?" 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 5 years ago.
Improve this question
I created a file named "?", is anybody know how to delete it?
It seems that ? is a special character in linux, I use Redhat as my OS.
I have already tried
rm ?
rm "?"
rm \?
They all failed and I got the error indicated that the file doesn't exist.
find the inode of the file:
ls -li
then delete the file using inode:
find . -inum <inode-number> -exec rm -i {} \;
BTW, rm ? works for me fine. here is my bash version:
# bash --version
GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
rm \? and rm "?" are both perfectly good ways to delete a file named ?. If they didn't work, and you still seem to have a file name ?, then it is most likely that the ? being shown is not really a ?, but rather the result of substituting an unprintable character with a ?. To see what the file is really called (with GNU ls) try:
ls --quoting-style=escape
Use this rm command to remove a file named ?:
rm ./\?
OR from another directory:
rm /path/to/\?
You can delete the file by its inode number. see the output bellow:
alplab:~/cad# ls -il
63051 -rw-r--r-- 1 root root 0 Nov 12 11:48 ?
alplab:~/cad# find . -inum 63051 -exec rm -i {} \;
I used the "find" command to delete the file with the inode number 63051 (the inode belonging to my "?" file).

Resources