I want to rename sub-directories to my new pattern but some results may be dangerous in my own script: For example if I use /tmp/etc as input argument I would have the nasty results in the first iteration: So in next iteration there will not be /tmp/etc to work at. The second problem in my script is when I use
Tag: grep
How do I grep/awk multiple lines from a cluster based on a pattern?
is there a way I can grep/awk multiple lines from a cluster based on a pattern? I have a file as follows: File.txt And the pattern is – “Dogs”, I would like the output to be: Is this possible? Answer or Notes: The first version loads the entire file into memory (but not the second). Both versions search the first
Searching two patterns in files that appear in the same file but may not appear on the same line
From a directory, I need to find all files that contain a decimal numbers say 42.7 AND the keyword “foo” or “goo”. How could I achieve that? Suppose I have a directory with three files The search command should give file1.txt and file3.txt. What is a search command to achieve this? i searched for the solutions but all I could
Filter out number from a specific line in log file
I have got a log file with specific String Need to get the specific number which is at the end of line. We can use awk or grep , not able to get this using below command. Since the log file has timestamp at the beginning. Answer Awk lets you easily grab the last element on a line. The variable
Bash regex for same sender and receiver with backreference
I try to make a regex (important that ist a regex because i need it for fail2ban) to match when the receiver and the sender are the same person: What am I doing wrong ? Answer You might use a pattern to match the format of the string between the brackets with a backreference to that capture. Explanation from Match
How do I find all files containing specific text on Linux but not in subdirectories?
Surprisingly i could not find an answer without sub directories. ie I guess without the -R option. What I was looking for was to search for text in a directory but avoid searching in subdirectories. Original post Tried But I get the error: Whereas if I try with: It still searched through subdirectories. Answer You can use: The * will
Encountered error using awk in an alias command (bash)
Good day, Im trying to create an alias using awk to filter based on a column which has number greater than a set limit. Its ok when used as a command line but when I assign it as an alias, it prompts error. $5 is column 5 on the grep output while 15 is the set limit. When I set
A confusion about the alias area of bashrc file
I want write my own alias called oepnserver. The functions of the oepnserver are: show my ip address use python module to start a server on current folder. The detailed code is listed below: When I type oepnserver, my terminal only shows: However, my expectation was I also try to use the ifconfig wlan0 |grep inet |awk ‘{print $2}’ along,
Linux Internal Process for Cat and Grep [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 2 years ago. Improve this question I’m newbie to linux back round process, for example i have the below linux command, Maybe the question will duplicate here but i couldn’t find
How do i extract some particular words from each line?
The text file has many lines of these sort , i want to extract the words after /videos till .mp4 and the very last number ( shown in bold ) and output each filtered line in a separate file Lets say for example the text file content is .. The output should be Answer You may try the below regex: