Skip to content
Advertisement

Tag: find

Linux find xargs command grep showing path and filename

find /folder/202205??/ -type f | xargs head -50| grep ‘^Starting’ There are 20220501 20220502 20220503 and so on folders… This command searches all first 50 lines of all files in ‘/folder/202205??/’ and shows the lines beginning with text “Starting” I haven’t the path and the filename of the files that are matched by the grep command. How can I get

Linux “find” command and highlight filename [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I am using the Linux find command. It looks through all the *.jar files and their contents and finds the word “foo” in them but

Copy files to another directory containing the same directory structure in bash

I have the following directory structure: Each class contains the exact same directories, and the directories contain png files. What I want to do is copy the contents from dir1 to dir2 such that dir2 has the following format: For example: dir2/i/*.png should contain all the files in dir1/class1/i/*.png, dir1/class2/i/*.png, dir1/class3/i/*.png, etc… I have tried doing the following: But I

How to copy a file to all subdirectories?

How can I paste read-me.jpg file into all sub-directories? Here is a command to create a new file in all subdirectories. But I want to copy jpg file into all subdirectories instead. Directory List: already tried with this command but no output Answer You tried to redirect cp’s output into $dir but instead we should specify the destination $dir/read-me.jpg as

Trying to find empty files in other user home directory

I want to search for empty files inside the home directory of the user “adam” for example. Now i don’t know the right path for that user, so I need to get it from /etc/passwd with the following command: Output: /home/adam (for example) Then executing this command to find the empty files. Is it possible to do this with one

Advertisement