Finding repeated names in a file

Hi i have a txt file with last name and name of people, now i want do use egrep to only display the names of the people with the same last name. I have no idea how i could do this. Thanks for help my txt looks like this: snow john snow jack miller g...
more »

2017-11-30 20:11 (2) Answers

Deleting a hidden cron job

Long story short, I have a cron job on my system that is displaying annoying messages. The cron is hidden on the system (that is, not located in the cron hourly, weekly, etc. I have also tried looking in /etc/crontab/ and /var/spool/cron/), making it...
more »

2017-11-19 22:11 (0) Answers

Regex to match IP addresses but ignore localhost

So I have this script that does something with IPs allocated to my OS (GNU/Linux) that I get from running ifconfig. It works fine, however, I was wondering if I could filter out loopback/localhost IP ( in the same regex expression [I assume...
more »

2017-11-08 16:11 (2) Answers

Find string in files with patterned exception

I need to find occurrences of strings in a list of files but there's an exception, say the text files have references to the word "world": This is the world And I updated "world" into "new world", so it becomes: This is the new world I ne...
more »

2017-10-27 02:10 (2) Answers

Regex for multiline output - sed / awk / grep

SVN log returns the below information but I am trying to get the revision number based on the comments. Since the returned value is in multiline, is there a way to use regex to look for '1712' (in last line) and then return the corresponding revisi...
more »

2017-10-26 22:10 (3) Answers

Grep resource usage

I have been tasked with writing a shell script to grep through hundreds of log files in many directories on Linux and Solaris servers. Some of the logs are compressed in many formats and some are a few GB in size. I am worried about grep using a lot ...
more »

2017-10-12 20:10 (1) Answers

Unable to grep the result count

I'm trying to find the specific type of files and grep the string "COMPLETED KO" and if the count is greater than 0 then it'll send the lines containg the string through mail. Below is the script: #!/bin/ksh cd /home/scripts/log FILES=`find . -...
more »

2017-10-12 15:10 (0) Answers

Search in CSV and count the entries

I have a csv file which imaging my inventory sort and uniq: |Nivcomp Nivelliergerät |Bosch Rotationslaser GRL 300 HV |Renault T440 |Renault Master |Spritzer Silo ... The second CSV file contains the complete inventory. I would like to find and co...
more »

2017-10-10 21:10 (0) Answers

Find references to files, recursively

In a project where XML/JS/Java files can contain references to other such files, I'd like to be able to have a quick overview of what has to be carefully checked, when one file has been updated. So, it means I need to eventually have a look at all f...
more »

2017-10-06 11:10 (1) Answers

How can I use grep with all available cores?

Problem: We know the string to look for but do not know which file to look in. for example.. say we have a file that contains the following. blah blah blah.... IMPORTANT NOTE: very important note ..... blah blah blah blah we do not know the ...
more »

2017-10-06 02:10 (2) Answers

Regex Match First Character of Column

I currently have a file called computers.txt ST 314, Fox, PC, Unix ST 13, Newman, Mac ST 212, Frank, Linux, PC BP 311, Jones, PC ST 404, Walden, PC, Linux ST 303, Noblitt, PC ST 102, Christensen, Mac ST 301, Ward, PC SB 444, Smith...
more »

2017-10-04 20:10 (3) Answers

grep -w is not unique if dash is in string

iIf a dash is in the string "grep -w" is not unique. How can I solve this? Example: File1: football01 football01test # grep -iw ^football01 football01 File2: football01 football01-test # grep -iw ^football01 football01 football01-tes...
more »

2017-09-28 17:09 (2) Answers

Regex using sed and or grep

How can I display the arch and version of queried rpm package using sed or grep? [root@kitchen-vm-centos6-box boot]# rpm -qa | grep kernel-devel kernel-devel-2.6.32-642.11.1.el6.x86_64 kernel-devel-2.6.32-696.10.2.el6.x86_64 What i need only is: ...
more »

2017-09-20 08:09 (5) Answers

Copy files containing all lines of an input file

I want to copy files in a directory which contain all the lines of an inputFile. Here is an example: inputFile Line3 Line1 LineX Line4 LineB file1 Line1 Line2 LineX LineB file2 Line100 Line10 LineB Line4 LineX Line3 Line1 Line4 Line1 The s...
more »

2017-09-13 08:09 (3) Answers

How to "grep" in array with dot "." precisely?

I'm trying to check if the user input $1 exist in an array. And here is my code: array=( aaa.bbb.ccc ) echo ${array[@]} | grep -o -w "$1" What I expect is only "aaa.bbb.ccc" or "" can be found. However, in this case, like "...
more »

2017-09-12 06:09 (2) Answers

java search with help of grep linux

I have the following java code to search on word in file, if that word found it stored the line contains that word in lista. List<String> lista = new ArrayList<>(); BufferedReader bf = null; String findWord = "city"; String line=""; bf =...
more »

2017-09-11 09:09 (0) Answers

Finding text inside a folder using terminal

I am trying to find a line of code in a folder and using the terminal. I use this command, which I think should work: MacBook-Pro:myWordpress myId$ grep "<?php get_template_part('loop', 'archives'); ?>" -R where the folder I am inspecting is...
more »

2017-09-09 10:09 (3) Answers

why doesn't grep work in this pattern with colon?

I know a colon : should be literal, so I'm not clear why a grep matches all lines. Here's a file called "test": cat test 123|4444 4546|4444 666666|5678 7777777|7890675::1 I need to match the line with ::1. Of course, the real case is more complica...
more »

2017-09-07 00:09 (4) Answers

Curl - Printing value using grep

I am fairly new at this curl scripting and I am looking for a way to paste a text from a token like value when I hit a specific site. Currently I have: echo $a_opensite | grep -E -o 'value=\".*==.*' | awk '{print $1}' > /Users...
more »

2017-09-04 23:09 (2) Answers