Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
0 answers
24 views
How does the search algorithm in Gnome Files traverse the directory tree?
If I place myself in some directory C and press the search lens and type some keywords, are files matching the keywords in directory C displayed first? This is not obvious, for instance if the search algorithm operated by alphabetical order (hence if there's some subfolder starting by "a" then resul...
If I place myself in some directory C and press the search lens and type some keywords, are files matching the keywords in directory C displayed first? This is not obvious, for instance if the search algorithm operated by alphabetical order (hence if there's some subfolder starting by "a" then results from that subfolder could be displayed before files from C which start by "b")
user324831 (113 rep)
Jun 2, 2025, 06:28 PM • Last activity: Jun 2, 2025, 07:12 PM
2 votes
1 answers
2856 views
Is there a command to start Nemo file manager and search for files?
Nemo is good at searching for files and folders. I use Nemo file manager in Xfce and would like to add the Nemo file-search action to WhiskerMenu in the same way Catfish is integrated to Whisker Menu following [this answer][1]: [![enter image description here][2]][2] Creating links to folders of oth...
Nemo is good at searching for files and folders. I use Nemo file manager in Xfce and would like to add the Nemo file-search action to WhiskerMenu in the same way Catfish is integrated to Whisker Menu following this answer : enter image description here Creating links to folders of other partitions in some location in $HOME and searching there would extend the search to those folders too, something that Catfish doesn't do. I would need a command that would start Nemo (by default in $HOME) and search for a variable file-name. During search, the CPU is put to work by the nemo process; enter image description here but nemo --help-all and man nemo show no useful options.
cipricus (1779 rep)
Oct 11, 2019, 12:57 PM • Last activity: May 5, 2025, 02:08 AM
0 votes
0 answers
105 views
Mobaxterm: in SFTP >>I am not able to search/find specific folder name in this list. Do we any option to do Search/Find in this folder list?
1. From this list, I am not able to do Search/Find for any specific folder name or file available in this directory. Any options available? 2. Also, not able to type and move to any folder or file. Ex: if i want to look for any folder starts with S / R / T.../W., then i need to scroll down to locate...
1. From this list, I am not able to do Search/Find for any specific folder name or file available in this directory. Any options available? 2. Also, not able to type and move to any folder or file. Ex: if i want to look for any folder starts with S / R / T.../W., then i need to scroll down to locate/check it. Any option available? Reference
Shanmuganathan K (1 rep)
Feb 24, 2025, 02:25 PM • Last activity: Feb 24, 2025, 03:37 PM
1 votes
4 answers
77 views
Looking to improve searches across large ( 7-10 GB files )
I have a need to search for many ( thousands) of dns within a large ( 7-10 GB) ldif file and print out the entries after it . I am mostly familiar with shell/python so tried to use awk for this and it works but it is a bit slow. I use a counter when it finds a matching line - print everything under...
I have a need to search for many ( thousands) of dns within a large ( 7-10 GB) ldif file and print out the entries after it . I am mostly familiar with shell/python so tried to use awk for this and it works but it is a bit slow. I use a counter when it finds a matching line - print everything under there and reset back to 0 if the line doesn't start with dn. I can't use grep -A because each entry can contain different number of lines to be printed . I don't have the means to import this into another ldap/db with indexing..just looking for something quick that I can use for now . if anyone knows any Linux-fu that can help please let me know! sorry I meant like the dn: pattern in an ldif file. For clarity - here is what I want I have a file with - dn: pattern1 phone: xxxx email: yyyy dn: pattern2 phone: xxxx email: yyy I have the dn: pattern that needs to be searched and the lines below that to be printed - till it reaches the next line with dn: . There is one empty line between entries. This is my code so far awk -v dn="$dn" ' BEGIN { counter = 0 } { if ($0 ~ /^dn: /) { if ($0 == dn) { counter = 1 } else if (counter) { exit } } if (counter) { print } } '
Yas V (11 rep)
Aug 2, 2024, 09:36 PM • Last activity: Sep 16, 2024, 03:00 PM
0 votes
2 answers
199 views
extending recursive find to .tar, tar.gz, tar.bz2, and tar.xz on Debian 12
Continuing https://unix.stackexchange.com/questions/34008/find-a-file-within-a-tar-gz-archive, how is it possible to automatically recursively search for files with given names, including the files inside the archives and compressed archives? For example, if `foo.tar.gz`, `dir1/bar.tar.bz2`, `dir2/d...
Continuing https://unix.stackexchange.com/questions/34008/find-a-file-within-a-tar-gz-archive , how is it possible to automatically recursively search for files with given names, including the files inside the archives and compressed archives? For example, if foo.tar.gz, dir1/bar.tar.bz2, dir2/dir3/foobar.tar.xz, and dir4/dir5/dir6/barfoo.tar are in the current directory, then
deepfind . -iname baz
(I made the name deepfind up) should look for the file named baz (in arbitrary case) not only in the usual directory structure below . but also in the contents of the four (compressed or plain) aforementioned tar archives. Our system is Debian 12, so that nobody attempts to suggest or even mention obsolete, uninstallable, or unusable software.
AlMa1r (1 rep)
Apr 27, 2024, 04:01 PM • Last activity: Jun 20, 2024, 08:37 PM
0 votes
1 answers
58 views
Retrieve the Following Occurrence of the String 'PWD' Once the Given String is Located
Below is my sample test.log file export SQRDIR=/v/orahome/Middleware/Oracle/bin64 export OID=ap0092 export PWD=pass1 export FDPWD=pass1 export AP0085_PWD=pass1 export SVR=AFFPROD export TWO_TASK=db01 export EF_OID=AP0093 export EF_PWD=pass2 export CCC_PER_OID=CCC_JAS export CCC_PER_PWD=pass3 export...
Below is my sample test.log file export SQRDIR=/v/orahome/Middleware/Oracle/bin64 export OID=ap0092 export PWD=pass1 export FDPWD=pass1 export AP0085_PWD=pass1 export SVR=AFFPROD export TWO_TASK=db01 export EF_OID=AP0093 export EF_PWD=pass2 export CCC_PER_OID=CCC_JAS export CCC_PER_PWD=pass3 export CAN_PER_OID=CAN_JAS export CAN_PER_PWD=pass4 ################################################### The user inputs ap0092. Upon this input, I need to search for the first occurrence of PWD after the first occurrence of the search string i.e. =ap0092 Thus, the desired output will be pass1 Likewise, for CCC_JAS the desired output will be pass3 I need the solution for Solaris OS. I was doing grep -A 1 [for non-Solaris] to get the next line but do not know how to search if the desired line may not be the very next line. Please note: There may be multiple lines or Whiteline between export OID=ap0092 and export PWD=pass1 Kindly suggest.
Ashar (527 rep)
Dec 4, 2023, 04:20 AM • Last activity: Dec 4, 2023, 08:48 AM
56 votes
11 answers
159659 views
How can I "grep" patterns across multiple lines?
It seems I am misusing `grep`/`egrep`. I was trying to search for strings in multiple line and could not find a match while I know that what I'm looking for should match. Originally I thought that my regexes were wrong but I eventually read that these tools operate per line (also my regexes were so...
It seems I am misusing grep/egrep. I was trying to search for strings in multiple line and could not find a match while I know that what I'm looking for should match. Originally I thought that my regexes were wrong but I eventually read that these tools operate per line (also my regexes were so trivial it could not be the issue). So which tool would one use to search patterns across multiple lines?
Jim (10550 rep)
Feb 2, 2014, 10:43 AM • Last activity: Sep 26, 2023, 04:37 PM
4 votes
1 answers
6195 views
Installing mlocate on mac OS 10.7
I'm a beginner in using Linux. I'm trying to use the command "locate". Once I use this command, I get an error that says the locate database should be created. I used the command below to create that database, but I still get the same error: sudo launchctl load -w /System/Library/LaunchDaemons/com.a...
I'm a beginner in using Linux. I'm trying to use the command "locate". Once I use this command, I get an error that says the locate database should be created. I used the command below to create that database, but I still get the same error: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist I tried so many things including installing locate, but the commands work in Ubuntu seem not to work in mac os. Does anybody know what the issue is? Thanks in advance,
Sam (151 rep)
Jul 2, 2013, 08:41 PM • Last activity: Mar 27, 2023, 12:56 PM
-3 votes
1 answers
1721 views
How to set up local Windows directory in WSL correctly?
I ran this script in Windows Subsystem for Linux at the command line. I wanted to search for the latest files but I got the error message "no such file or directory", and so I wonder how do I change my script to make it work? Here's my script: ``` # Set the path to the directory where you want to se...
I ran this script in Windows Subsystem for Linux at the command line. I wanted to search for the latest files but I got the error message "no such file or directory", and so I wonder how do I change my script to make it work? Here's my script:
# Set the path to the directory where you want to search for the latest file
directory="C:/Users/nguyen_q/Downloads/Test files/*.csv"

# Get the current date in the format YYYY-MM-DD
echo CURRENT_DATE=$(date +%Y%m%d) 

# Set the variable to hold the name of the latest file
latest_file="" 

# Find all files in the specified directory whose name starts with "MNSUP"
echo files="$(find "$directory" -maxdepth 1 -name "MNSUP*")" 

# Sort the files by modified time, with the most recently modified file first
echo files="$(ls -t $files)" 

# Set the first file in the list as the latest file
echo latest_file="$(echo "$files" | head -n 1)" 

# Check if the latest file contains the current date in the file name
if [[ "$latest_file" == *"$CURRENT_DATE"*.csv ]]; then
  # Print a message if the latest file matches the current date
   echo "$latest_file TODAYYYYY."

else
  # Print a message if the latest file does not match the current date
  echo "$latest_file"

  # Send an email to the user
  echo "The latest file is not present and was not sent to MN.Please re run the job" | mail -s "Latest File Error" "$anna.nguyen@companyname.com"    
fi 

# Print the latest file
# echo "The latest file currently in the folder is: $latest_file"
Anna Nguyen (21 rep)
Jan 5, 2023, 09:13 PM • Last activity: Jan 7, 2023, 05:04 PM
0 votes
1 answers
31 views
search for a section of log that was appended upon execution of script
I'm using WebLogic start script `startmymanageserver1.sh` that writes(appends) to a `managedserver.log` log file every time it is executed. The `managedserver.log` may have logs from the past few months which I cannot override. I wish to `grep` for a string `Server is in RUNNING State` not from the...
I'm using WebLogic start script startmymanageserver1.sh that writes(appends) to a managedserver.log log file every time it is executed. The managedserver.log may have logs from the past few months which I cannot override. I wish to grep for a string Server is in RUNNING State not from the entire managedserver.log; but only from the section of logs that was appended as a result of my executing the startmymanageserver1.sh Can you please suggest how to grep from only the section of managedserver.log that was updated as a result of my last run of startmymanageserver1.sh?
Ashar (527 rep)
Dec 23, 2022, 01:26 PM • Last activity: Dec 26, 2022, 02:00 PM
8 votes
2 answers
9661 views
more less ...skipping... when searching
When I search a file in less or more, it will remove lines and replace them with "skipping". Does anyone know what causes this and/or how to avoid it? After I '/' search a log file using either more or less, I see this: crw-rw-rw- 1 root staff 40, 0 Oct 27 2013 fscsi0 crw-rw-rw- 1 root staff 40, 1 O...
When I search a file in less or more, it will remove lines and replace them with "skipping". Does anyone know what causes this and/or how to avoid it? After I '/' search a log file using either more or less, I see this: crw-rw-rw- 1 root staff 40, 0 Oct 27 2013 fscsi0 crw-rw-rw- 1 root staff 40, 1 Oct 27 2013 fscsi1 brw-rw---- 1 root system 10, 9 Oct 27 2013 hd1 ...skipping... crw-rw-rwT 1 root system 38, 7 Oct 27 2013 vhost7 crw-rw-rwT 1 root system 38, 8 Oct 27 2013 vhost8 crw-rw-rwT 1 root system 38, 9 Oct 27 2013 vhost9 crw------- 1 root system 12, 0 Oct 27 2013 vio0 crw------- 1 root system 20, 0 Apr 5 00:53 vty0 drwxr-xr-x 2 root system 256 Oct 15 2008 xti crw-rw-rw- 1 root system 2, 3 Oct 27 2013 zero ...skipping... crw-rw-rwT 1 root system 38, 7 Oct 27 2013 vhost7 crw-rw-rwT 1 root system 38, 8 Oct 27 2013 vhost8 crw-rw-rwT 1 root system 38, 9 Oct 27 2013 vhost9
kdoggett (83 rep)
Apr 5, 2016, 09:44 PM • Last activity: Jul 8, 2022, 10:50 PM
0 votes
1 answers
1083 views
Unzip files with the same name from multiple directories
I have the file `archive.zip` located in multiple directories, i.e.: ``` dir/001/archive.zip dir/002/archive.zip dir/003/archive.zip ... ``` Is there a way in which I can recursively unzip all the `archive.zip` files from all the directories with different names, using command line? The content of t...
I have the file archive.zip located in multiple directories, i.e.:
dir/001/archive.zip
dir/002/archive.zip
dir/003/archive.zip
...
Is there a way in which I can recursively unzip all the archive.zip files from all the directories with different names, using command line? The content of the ZIP files should be extracted to the same directory where the ZIP file resides. The dir folder is common, only the parents of archive.zip have different names. Thank you in advance!
Ailema (1 rep)
Jun 2, 2022, 08:52 AM • Last activity: Jun 3, 2022, 09:44 AM
2 votes
3 answers
855 views
How to list backup files missing corresponding real files?
I accidentally deleted some files spread across my home directory, but I do not know exactly which ones were removed. How can I get a list of all backup files missing their corresponding file? (equivalently, files having names ending with a tilde, without there being another file in the same directo...
I accidentally deleted some files spread across my home directory, but I do not know exactly which ones were removed. How can I get a list of all backup files missing their corresponding file? (equivalently, files having names ending with a tilde, without there being another file in the same directory with the same name sans trailing tilde?) I tried a few things so far; although I don't remember the exact flags, it was something like: grep -Rlv '(.*)\n\\1~|.*(?!~)' That didn't work, and neither did: ls -R | grep -v '(.*)\n\\1~|.*(?!~)' How can I find these files?
AJMansfield (924 rep)
Mar 11, 2014, 01:14 AM • Last activity: May 13, 2022, 03:01 PM
0 votes
2 answers
99 views
How to search for 3 specific things within a file?
Within the file, `security.log` I need to find how many IP addresses have the most DNSBL 5 rankings. This is what a line in this file can look like: ``` Oct 24 00:00:28 MAIL-00 postfix/postscreen[10909]: dnsbl rank 5 for [103.129.47.51]:50807 ``` To filter out IP addresses with DNSBL rankings, I did...
Within the file, security.log I need to find how many IP addresses have the most DNSBL 5 rankings. This is what a line in this file can look like:
Oct 24 00:00:28 MAIL-00 postfix/postscreen: dnsbl rank 5 for [103.129.47.51]:50807
To filter out IP addresses with DNSBL rankings, I did:
grep "ip" security.log | grep -i "DNSBL" security.log
Or I could write a shell script to help, I was thinking something like:
#!/bin/bash

#grep every ip with "dnsbl rank 5"
#count the amount of times each unique one appears, create variable with IP and value is the number of times it appears
#Find the variable with the biggest value and output the variable name to screen
The script would need to cut out the other stuff, so the output to search from is just a list of IPs that had "dnsbl ran 5" before it. I haven't used cut in a long time, would that be the best way to only get the IP inside the brackets? If someone could help me out, I'd really appreciate it!
echo_LOGNAME (1 rep)
Mar 9, 2022, 05:55 PM • Last activity: Mar 10, 2022, 05:11 AM
3 votes
2 answers
1860 views
Only output the name of file containing a pattern (without the line output) using grep
I want to list the files that contain a pattern, without outputting the line(s) containing the pattern.  I assume that it's possible to do this with `grep`.  How should I use `grep` in that sense?  For example, the following command gives all the lines containing "stringpatt...
I want to list the files that contain a pattern, without outputting the line(s) containing the pattern.  I assume that it's possible to do this with grep.  How should I use grep in that sense?  For example, the following command gives all the lines containing "stringpattern" (case insensitive) in all the .txt files.  I want to have only the name of the file (± the line number).
grep -ni stringpattern *.txt
Ideally, if the string/pattern is present more than once in one file, I would like to have multiple lines of output for that file.
ecjb (475 rep)
Jan 30, 2022, 02:12 PM • Last activity: Feb 1, 2022, 11:48 PM
0 votes
1 answers
140 views
Search for all videos created on a Saturday
I am using **Linux Mint**. There are several years worth of files and folders scattered everywhere. My goal is to find a way to search my entire hard drive for any **video files** that were **created on a Saturday**, I do not know the date in number format. I do not know the file name, nor the file...
I am using **Linux Mint**. There are several years worth of files and folders scattered everywhere. My goal is to find a way to search my entire hard drive for any **video files** that were **created on a Saturday**, I do not know the date in number format. I do not know the file name, nor the file extension, but they were certainly videos. I am preferably looking for a GUI program where I can see a thumbnail of the video file, to save me from having to manually open each one. But, failing that a command line solution is also okay.
securityauditor (101 rep)
Dec 15, 2021, 05:59 PM • Last activity: Dec 15, 2021, 09:55 PM
2 votes
1 answers
396 views
Find Files Recursively With Different ACLs
How would I go about finding all files recursively that have ACLs different from what I'm searching for? For example I would like to find all files in a directory that have ACLs that are not identical to the following example: # owner: bob # group: bobs-group user::rwx user:fred:rwx group::rw- mask:...
How would I go about finding all files recursively that have ACLs different from what I'm searching for? For example I would like to find all files in a directory that have ACLs that are not identical to the following example: # owner: bob # group: bobs-group user::rwx user:fred:rwx group::rw- mask::rwx other::r-- Using a separate search I'd like to be able to do the same for directories, but with slightly different permissions.
Harry Muscle (2697 rep)
Dec 15, 2021, 05:15 AM • Last activity: Dec 15, 2021, 01:19 PM
4 votes
2 answers
1293 views
Find XML file with specific path
I'm working with XML files, each of which could be dozens of lines long. There are literally hundreds of these files, all over a directory structure. Yes, it is Magento. I need to find the file that has the ` ` element. A ` ` tag could be defined under other tags, so **I need to search for the full...
I'm working with XML files, each of which could be dozens of lines long. There are literally hundreds of these files, all over a directory structure. Yes, it is Magento. I need to find the file that has the ` element. A ` tag could be defined under other tags, so **I need to search for the full path** not just the end tag or tags. There could be dozens of lines between each tag, and other tags between them: ... 50 lines .... ... 50 lines .... Vital information here **What is the elegant, \*nix way of searching for the file that defines ``?** I'm currently on an up-to-date Debian-derived distro. This is my current solution, which is far from eloquent: $ grep -rA 100 foo * | grep -A 100 bar | grep -A 100 boom | grep bang | grep -E 'foo|bar|boom|bang'
dotancohen (16493 rep)
Aug 1, 2021, 11:53 AM • Last activity: Aug 1, 2021, 06:27 PM
0 votes
1 answers
3973 views
How to search for hidden files and folders in dolphin?
I'd like to be able to search for hidden files and folders in dolphin. Currently I was trying to search for backups of the .bash_history file but no results showed up despite hidden files being set to visible in dolphin. Is there a way to make dolphin show hidden files and folders in the search resu...
I'd like to be able to search for hidden files and folders in dolphin. Currently I was trying to search for backups of the .bash_history file but no results showed up despite hidden files being set to visible in dolphin. Is there a way to make dolphin show hidden files and folders in the search results if hidden files are visible in the folder? If it's not possible with dolphin as is maybe there's an extension for it? This forum post and the bug report linked therein are relevant. An improvised solution is to search for files with find . -name .bash_history.
mYnDstrEAm (4708 rep)
Apr 25, 2020, 09:50 AM • Last activity: Apr 15, 2021, 02:23 AM
2 votes
1 answers
7518 views
Find recursively all files whose content match a specific regular expression
I like to search all PHP files and find a particular string that is identified by a regular expression. The regular expressions that I use to find the string is: \$[a-zA-Z0-9]{5,8}\s\=\s.{30,50}\;\$[a-zA-Z0-9]{5,8}\s\=\s[a-zA-Z0-9]{5}\(\) I tried to use: grep -r "\$[a-zA-Z0-9]{5,8}\s\=\s.{30,50}\;\$...
I like to search all PHP files and find a particular string that is identified by a regular expression. The regular expressions that I use to find the string is: \$[a-zA-Z0-9]{5,8}\s\=\s.{30,50}\;\$[a-zA-Z0-9]{5,8}\s\=\s[a-zA-Z0-9]{5}\(\) I tried to use: grep -r "\$[a-zA-Z0-9]{5,8}\s\=\s.{30,50}\;\$[a-zA-Z0-9]{5,8}\s\=\s[a-zA-Z0-9]{5}\(\)" *.php but this does not seem to work. find . -name '*.php' -regex '\$[a-zA-Z0-9]{5,8}\s\=\s.{30,50}\;\$[a-zA-Z0-9]{5,8}\s\=\s[a-zA-Z0-9]{5}\(\)' -print Does not work either. I need is to search a path and all subdirectories for PHP files that contain a string identified by the regular expression stated above. What is the best way to accomplish this? For your information this is a string similar to the ones I try to find: As you probably realize, this is a malware code. So this string is similar but different on each file. However the regular expression code does a good job finding all files if it contains a similar content somewhere in the file. Before, I had downloaded all files to my windows PC and then used EMEditor to search by regular expression. This works fine on the PC, but for this I need to download everything and it would be nice to be able to search direct on Linux command prompt. Any tip would be very much appreciated.
TAPIO (23 rep)
Feb 2, 2021, 05:46 AM • Last activity: Feb 5, 2021, 02:41 PM
Showing page 1 of 20 total questions