find -exec with multiple commands

I am trying to use find -exec with multiple commands without any success. Does anybody know if commands such as the following are possible? find *.txt -exec echo “$(tail -1 ‘{}’),$(ls ‘{}’)” \; Basically, I am trying to print the last line of each txt file in the current directory and print at the end … Read more

ls command: how can I get a recursive full-path listing, one line per file?

How can I get ls to spit out a flat list of recursive one-per-line paths? For example, I just want a flat listing of files with their full paths: /home/dreftymac/. /home/dreftymac/foo.txt /home/dreftymac/bar.txt /home/dreftymac/stackoverflow /home/dreftymac/stackoverflow/alpha.txt /home/dreftymac/stackoverflow/bravo.txt /home/dreftymac/stackoverflow/charlie.txt ls -a1 almost does what I need, but I do not want path fragments, I want full paths. 26 … Read more

Python: Find in list

What is the most ‘pythonic’ way of finding an item in a list? Is it: if item in my_list: print(“Desired item is in list”) 13 s 13 As for your first question: that code is perfectly fine and should work if item equals one of the elements inside myList. Maybe you try to find a … Read more

How can I exclude all “permission denied” messages from “find”?

I need to hide all permission denied messages from: find . > files_and_folders I am experimenting when such message arises. I need to gather all folders and files, to which it does not arise. Is it possible to direct the permission levels to the files_and_folders file? How can I hide the errors at the same … Read more

How do I find all files containing specific text on Linux?

Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. without enough detail may be edited or deleted. I’m trying to find a way to scan my entire Linux system for all files containing a specific string of text. Just to clarify, I’m … Read more