Skip to main content

All Questions

Tagged with
-1 votes
2 answers
67 views

set output into variable from grep from input variable

whats wrong with this bash script: acme2=$(dig txt @$1 _acme-challenge.$1.de) acme3=$(echo $acme2 | grep "^_acme") ...
dg1kpc's user avatar
  • 1
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
0 votes
1 answer
100 views

bash script, grep, arguments in VAR?

I have a list of file names where I wish to remove items containing different letters or strings. If I run cat <file> | grep -Ev 'P1|P2' in a bash shell it works. but in a script #!/bin/bash ......
user3866319's user avatar
1 vote
2 answers
332 views

Finding a string in a txt of house addresses with number ranges by passing in exact number and street names

Context I'm a postal worker (mail sorter) and am trying to write a bash script which allows me to input an exact street address and first couple letters of a street name, and have it return the ...
YMGenesis's user avatar
0 votes
1 answer
103 views

Error with sed replacing string

Hello I need to replace a string but i receive error using string 'return false;' #!bin/bash oldstring='{alert("bash")}' newstring='{return false;}' grep -rl $oldstring /home/commons.bundle....
Giuse Esse's user avatar
1 vote
3 answers
2k views

How do I grep from one character or pattern to another?

I want to grep a string from a given character or pattern until another given character or pattern instead of the entire line. For example: $ > echo "The brown fox jumps over the lazy dog" | grep ...
ntruter42's user avatar
  • 197
2 votes
1 answer
759 views

grep -v without output?

I have an issue with a script. Here is the code (with line numbers): 1 function usage 2 { 3 echo "usage: $0 filename ..." 4 echo "ERROR: $1" 5 } 6 7 if [ $# -gt 0 ] 8 then name=(...
Yoshi24517's user avatar
0 votes
2 answers
248 views

Bash scripting loop concatenate pipes / redirections based from names variable

I have a command that produces a number of output lines that I later grep searching for. Based on a past answer I know I can use a single long command and do all my filters concurrently: https://...
Luis Díaz's user avatar
3 votes
2 answers
1k views

grep files with pattern A but exclude files with pattern B

I want to grep files which include pattern A (iwant) but I want to exclude files which contain pattern B (idontwant). Example: read -p "...what are you looking for: " iwant read -p "...what should ...
terpentin's user avatar
7 votes
1 answer
4k views

Convert json file to a "key-path" with the resulting value at the end of each "key-path"

I have a large and relatively complex json configuration file that I want to search for keys and/or values using simple tools like "grep". When I 'grep' the file I would like to have in the output ...
Christopher Morris's user avatar
0 votes
0 answers
340 views

Building a script to find a file if exists and grep for a string

Following K7AAY and 0xSheepdog advice I'll rephrase. I need to create a bash script where it will grep a log file that is generated daily when a file is sent in a range of time of the day. The ...
anmoreira's user avatar
0 votes
3 answers
2k views

Syntax error near unexpected token ` | '

I keep getting this error line 3: Syntax error near unexpected token `|' This is the script at the moment: for filename in $(ls $1) | grep -v ".old" do mv "$1/$filename" "$1/$filename.old" done ...
Evan Jack's user avatar
0 votes
1 answer
2k views

Bash script to monitor log, match keyword then send commands [duplicate]

#!/bin/bash sudo tail -fn0 /home/main/time.log | grep -o --line-buffered 'garage\|garden\|porch' | head -1 | while read line; do sudo pkill -f porch.sh & sudo pkill -f garage.sh & done I'...
fizers's user avatar
  • 1
4 votes
2 answers
5k views

wc -c gives me one extra character count

So I made a script that adds users to the system, and I wanted to force the length of the usernames to 8 characters or below. #!/bin/bash # Only works if you're root for ((a=1;a>0;a)); do if [[ ...
iamAguest's user avatar
  • 543
1 vote
3 answers
3k views

find a file through particular search in while loop [closed]

Actually it is related to my previous post sorting out directories by searching certain file extension which is still unanswered. There are many options available to solve the problem, but I am ...
Akand's user avatar
  • 69

15 30 50 per page