Skip to main content

All Questions

Tagged with
0 votes
2 answers
44 views

Capture and print on the exact match from a file

I am trying to use grep to match only a specific part of a row in a file. The file is a huge csv file with some columns containing json with commas so it is hard to figure out which column what I am ...
smith's user avatar
  • 161
-2 votes
3 answers
231 views

Bash script: echo output of variable and write to file

I am trying to write a script which will check to see if the contents of a file match a certain value and if so, overwrite it with contents of another file. Example: file1 = A, B, C, D 1, 2, 3, 4 ...
Joseph Woodward's user avatar
8 votes
5 answers
2k views

How to execute a command on all files whose names match a pattern and whose contents match a pattern?

Say I want execute cmd on all *.cpp and *.hpp files that contain the word FOO. As far as just finding those files goes, I know I can do, find /path/to/dir -name '*.[hc]pp' -exec grep -l 'FOO' {} + ...
Enlico's user avatar
  • 2,179
2 votes
2 answers
334 views

Why does awk concatenate strings from different lines

Good day. I'm trying to run a ping6 on IPv6 addresses pulled from /etc/resolv.conf.dnsph. It seems though, as if awk is stringing the IPv6 addresses onto one line. $ grep ^nameserver /etc/resolv.conf....
Bjoern's user avatar
  • 31
1 vote
1 answer
1k views

Grep from bash return No such file or directory but work if the same command executed manually from CLI

If i execute below bash script named test.sh, I receive this error: ./test.sh: line 8: grep -irl -e"1234567891" ./save: No such file or directory If I execute the line above taken from ...
Marco's user avatar
  • 121
0 votes
2 answers
113 views

Writing a regular expression to list IPv4 addresses found in a docker network

Hello while inspecting the characteristics of a docker network with the command docker network inspect network59 , I noticed the precence of ipv4 address and I would like to write a regular expression ...
Mnako8's user avatar
  • 15
0 votes
1 answer
309 views

grep data between two timestamps

I am so beginner with linux . Oct 07 11:00:33 some text Oct 07 12:00:33 some text Oct 08 14:00:33 some text Oct 08 21:00:33 some text Oct 09 21:00:33 some text I would like ...
morteza mortezaie's user avatar
0 votes
1 answer
599 views

regular expression - command not found on terminal

I am trying to grab my_name 369 from file.txt I input this grep line with regex but it return an error. I have tried using egrep and it did not work. Input: my_name 369 == match my_name 161 == match ...
JakePaul's user avatar
0 votes
4 answers
528 views

Changing the name of a file based on a part of its original name that are between the first two instances of a character

I am trying to change the names of my files based on the string between the first two instances of "|". This is what my problem looks like: >1234|interest1|randomstuff1.txt >5678|...
Fernando 's user avatar
0 votes
1 answer
209 views

I'm trying to understand how to shorten regex

I'm trying to list all directories that are 1GB or larger. I know I could use ncdu, but at the moment, I'm just trying to understand how to shorten regex... I found this command, du -h . | grep '[0-9\....
Marslander's user avatar
13 votes
2 answers
36k views

How to grep multiple strings when using with another command?

I am trying to find out how I can use: grep -i With multiple strings, after using grep on another command. For example: last | grep -i abc last | grep -i uyx I wish the combine the above into one ...
Niek Jonkman's user avatar
6 votes
1 answer
14k views

Grep a list of strings [closed]

I have a multiple strings that I want to find them in a list of files that are in a same folder. So, I want to put all the strings in a sort of list and then apply the command: grep -l string *,so I ...
Luciano Muratore's user avatar
0 votes
1 answer
2k views

Finding a string in multiple folders that are in the same directory

I have a directory A that has multiple folders, and I want to find a string in those folders. How can I do it? I have tried grep -rw string * in A, but it takes a lot of time.
Luciano Muratore's user avatar
1 vote
2 answers
2k views

How to programmatically maintain umask in /etc/profile and /etc/bashrc

I am looking for a way to programmatically maintain a consistent umask in the files /etc/profile and /etc/bashrc. They have an entry such as follows: if [ $UID -gt 199 ] && [ "`/usr/bin/...
Kyle's user avatar
  • 11
1 vote
2 answers
627 views

grep not working with filename from for loop

learning bash scripting and i'm trying to filter results with a nested grep in a for loop: sample filenames: this-file_AAC.txt this-other_file_AAAC.txt yep-a-file_AAC.nfo oops_another_one....
WhiteRau's user avatar
  • 255

15 30 50 per page
1
2 3 4 5