Skip to content

Tag: grep

dont understand Linux command

I’m working on existing php project and I’m totally beginner with that . I ‘m trying to understand this line of code . I’ve searched alot and I know that exec is used to run unix command . But I don’t understand the first part /usr/local/sbin/clog ‘/var/log/filter.log’ I also dont understand | meaning here also I don’t understand this part

echo printing working directory files names for no reason

why echo printing the files names ? gives this output but running pacmd list-sinks | grep “index:” in the shell gives * index: 1 index: 2 index: 3 Answer pacmd returns * pattern. In for … in …; do … done loop, the list pattern contains * without any protection. So, bash replace * by all files found in current

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

grep all .js urls from text file

There is a File a.txt I want to grep all .js extension URLs so I tried this but it not showing https://site.tld/b.js?query=1 And when I tried this, It also select js name from anywhere Thanks in advance Answer Just escape the . with a

reading and analyzing a text file with bash script

I want to read a log file and want to extract 5-6 number digit that is written right next after the keyword “salary”. And then want to analyze if the salary is above 2000. If there is even one above 2000, it is a MNC otherwise unknown. After writing the salary, the line ends mostly but sometimes there is an

How to replace newlines between brackets

I have log file similar to this format Here is the echo command to produce that output $ echo -e “test {nseq-cont {nttt0,nttt67,nttt266nttt},nttgrp-id 505nt}n}ntest{nttest1{nttvalnt}n}n” Question is how to remove all whitespace between seq-cont { and the next } that may be multiple in the file. I want the output to be like this. Preferably use sed to produce the output.

Filter followed tail to file using grep and redirect

I want to get the output of tail -f /var/log/apache2/error.log | grep “trace1” into a file. But tail -f /var/log/apache2/error.log | grep “trace1” > output.txt does not work, while the first command gives an output in my terminal window as expected. I guess it has to do with the follow-parameter, because if I omit the “-f”, the output file is

Replacing line of text cointing using sed

I’m trying to replace document.querySelector(‘.popup’).classList.add(‘active’) by document.querySelector(‘.popup’).classList.add(‘noactive’) Answer You can use See the online demo. The regex is POSIX BRE compliant and matches (document.querySelector(‘.popup’).classList.add(‘) – Group 1 (1): a literal document.querySelector(‘.popup’).classList.add(‘ text (active’)) – Group 2 (2): a literal active’) text. Note the capturing groups in a POSIX BRE regex are set with (…). The literal dots need escaping and