I have several strings(or filenames in a directory) and i need to group them by second most common pattern, then i will iterate over them by each group and process them. in the example below i need 2 from ACCEPT and 2 from BASIC_REGIS, bascially from string beginning to one character after hyphen (-) and it could be any character
Tag: grep
How to compare the columns of file1 to the columns of file2, select matching values, and output to new file using grep or unix commands
I have two files, file1 and file2, where the target_id compose the first column in both. I want to compare file1 to file2, and only keep the rows of file1 which match the target_id in file2. file2: Any help would be appreciated. % grep -x -f file1 file2 resulted in no output in my terminal Answer Sample data that actually
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
Operators and user input not found / unexpected while checking if users and groups exist in /etc/group and /etc/passwd
I can’t understand what’s wrong with my code. I’m trying to make it so that if the passed in username and group are both not found in /etc/group and etc/passwd echo both not found. If one but not the other is found echo one is found and finally if they are both found then echo both exist. Here is my
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
How to grep multi line string with new line characters or tab characters or spaces
My test file has text like: I am trying to match all single lines ending with semicolon (;) and having text “dummy(“. Then I need to extract the string present in the double quotes inside dummy. I have come up with the following command, but it matches only the first and third statement. With -o flag I expected to extract
grep AND Operations
I want to simulate AND operation in grep . List all the file files contains “Some Words” and contain “Some Other Words” anywhere in the file. So far I tried # but it is not working. Answer Using GNU tools: The first grep lists files (-l) containing string1 -i: case insensitive, -r: recursive, -Z: file list delimited by ascii null
How to grep text patterns from remote crontabs using xargs through SSH?
I’m developping a script to search for patterns within scripts executed from CRON on a bunch of remote servers through SSH. For now I can’t get the correct output. Script on client machine This only gives me the paths of scripts from crontab, not the matched lines and line number plus the first line is prefixed with “grep:” keyword (example