Quantcast
Channel: User Gilles Quénot - Stack Overflow
Browsing latest articles
Browse All 65 View Live

Comment by Gilles Quénot on Using Inline variables in command line commands

OP can use a subshell if needed: ( x=foobar; echo ... )

View Article



Comment by Gilles Quénot on Bash: checking gzip using == or "| grep"

Post edited accordingly, thanks

View Article

Comment by Gilles Quénot on How to automatically answer "more" command

Yes, tested, works

View Article

Answer by Gilles Quénot for How to iterate through more than two 'levels' of...

Given this files/directories structure:$ tree folder/folder/├── lever1_1│└── level2_1│└── level3_1│├── file1.txt│└── file2.txt└── lever1_2└── level2_1└── level3_16 directories, 2 filesWhat you...

View Article

Answer by Gilles Quénot for check status connected nordvpn bash script

What I would do:status="$(nordvpn status | head -n 1)"printf "STATUS %s\n" "$status"if [[ $status == "Status: Disconnected" ]]then echo "Disconnected from VPN..." nordvpn connect...

View Article


Image may be NSFW.
Clik here to view.

Answer by Gilles Quénot for grep: color different parts of output

With grep, this looks convoluted.What I would do:#!/bin/bashblue=$(tput setaf 4)red=$(tput setaf 1)reset=$(tput sgr0)cat<<EOF | sed -e "s/.*/$blue&$reset/g" -e "s/\[JIRA REF\]/$red\[JIRA...

View Article

Answer by Gilles Quénot for my flask api doesnt get my port even if i specify it

You need in the Dockerfile:CMD ["./run.sh", "./project/main/userapi.py", "5555"]where 5555 is the port you want to bind.Your if statement test the numbers of arguments: as far as you don't pass any,...

View Article

Answer by Gilles Quénot for bash: while read -r using

You need another syntax:while read -r key datedo age=$(gdate -d "$date" +%s) #do stuff with $key and $date # $key should be 'expiresOn' and $date should be eg '2024-03-02T00:00:00Z'done < <(cat...

View Article


Answer by Gilles Quénot for bash get correct expansion of an array member in...

You need more quotes!VAR[0]="ls"VAR[1]="ls -la"for i in "${VAR[@]}"do $idoneLearn how to quote properly in shell, it's very important :"Double quote" every literal that contains spaces/metacharacters...

View Article


Answer by Gilles Quénot for Regex that finds both integers, decimals, and...

Try:-?[\d.]+(?:\,\d+)?;{1,2}\s*EURRegex Demo

View Article

Answer by Gilles Quénot for Using Selenium to locate element in iframe

Your page use an iframe.So, this is a working code with valid XPath:from selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.common.by import Byval =...

View Article

Answer by Gilles Quénot for Separating the last number in each line from the...

Try to understand what is the most smart way to achieve this.It's better to avoid using a regex that match all the line, instead try to find the portion that need change.Using sed with -E aka Extented...

View Article

Answer by Gilles Quénot for awk CSV parsing using FPAT result in wrong output

It looks like you don't use GNU awk.You need to install GNU version with homebrew:brew install gawk

View Article


Answer by Gilles Quénot for awk with exclude pattern in shell

Like this:awk '!/-event-group-/{print} /-event-group-13]/{print}' file ^ look hereorawk '!/-event-group-/{print} /-event-group-13\y/{print}' file\y is word boundary for GNU awk.Yields:---...

View Article

Answer by Gilles Quénot for sed with literal string--not input file

You have a single quotes conflict, so use:echo "A,B,C" | sed "s/,/','/g"If using bash, you can do too (<<< is a here-string):sed "s/,/','/g" <<< "A,B,C"but notsed "s/,/','/g"...

View Article


Answer by Gilles Quénot for how to ignore chromedriver errors from showing up...

Try to add this line:options.add_argument("--log-level=3")0: verbose1: info2: warning3: error

View Article

Answer by Gilles Quénot for Prevent repeated sequence in domain url

What I would do, always simplify your sample at minimum like I does to isolate the issue:^([a-z]+).*?(?!\.\1)(?:\.[a-z]+)+$ ^------^ ^^capture group captured groupRegex Demo

View Article


Answer by Gilles Quénot for How to grep my one-line file with constant key?

What I would do:grep -oP '__version__="\K[^"]+'-o display only the matched part-P allow PCRE regexesThe backquote is used in the old-style command substitution. The foo=$(command) syntax is recommended...

View Article

Answer by Gilles Quénot for Want to highlight if certain condition match with...

You can do it like this:with perl:df -h | perl -anE ' (my $p = $F[4]) =~ s/%//; if ($p >= 80) { system("tput setaf 1"); print; system("tput sgr0") } else { print }'Or with just bash:df -h | while...

View Article

Answer by Gilles Quénot for Tar: Cannot stat: No such file or directory

You need to prevent word splitting:find ...... -print0 | xargs -0 tar zcf "$backup_dir/$file.tar.gz"See: https://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html

View Article

Answer by Gilles Quénot for Why does $'\141' convert to ASCII 'a' as...

If you have error, it's simply a syntax error.What you need to construct ASCII letters from variables:i=141; printf '%b\n''\'$iaor to construct from multiple variables (only 2 needed):start='\'...

View Article


Answer by Gilles Quénot for How to form a regex for a double quote that may...

You need:boundary="?([^"]+)"?Only one capture group used.JS Demo:const input1 = 'boundary="-------Embt-Boundary--1261032946D275CF"';const input2 =...

View Article


Comment by Gilles Quénot on a script that outputs the type of file, is it...

Yes, you can implement other cases, like video and so on. *) is a catch all for not listed cases

View Article

Answer by Gilles Quénot for Websites Web Scraping Emails using Python

The issue is not the regex:from bs4 import BeautifulSoupimport requestsimport reurl = 'https://s7health.pl/kontakt/'response = requests.get(url)soup = BeautifulSoup(response.content,...

View Article

Comment by Gilles Quénot on How to change urlencode spaces inside a sed...

Most *Unix have both sed& perl. That's shell, you are not limited to use just one tool but awk, sed, ed, tr, paste, cut; perl, and so on.

View Article


Comment by Gilles Quénot on Awk switching output field seperator depending on...

You should minimize the issue to be reusable by futur readers. Looks too specific to your needs. Please, read How to create a Minimal, Complete, and Verifiable Example.

View Article

Comment by Gilles Quénot on How to separate an array from a command using...

grep | awk | awk, really ? oO Use jq instead.

View Article

Comment by Gilles Quénot on Add and Replace Jobs in Crontab

You just need to add a basic sed command to other commands from the linked answer. Like sed 's!\.sh$!& \&>/dev/null 2>\&1!' file

View Article

Comment by Gilles Quénot on How to separate an array from a command using...

So parsing JSON with awk or bash is a good practice for you? No better way?

View Article



Comment by Gilles Quénot on Bash: How to assign the value of an environment...

Why BITBUxCKET_TAG instead of BITBUCKET_TAG ??

View Article

Answer by Gilles Quénot for How to separate an array from a command using...

What I would do using jq:jq -r '"ID: \(.id)Course name: \(.course_name)Creator name: \(.creator.nnid)"' file.jsonYields:ID: 66782542Course name: goCreator name: Khanna1974

View Article

Comment by Gilles Quénot on Is it possible to scrape data from Sofascore on...

Missing crucial information: what is the error you get? I get a 403 error.

View Article

Comment by Gilles Quénot on How to find if file names are similar being...

Are they duplicated files you want to remove?

View Article


Comment by Gilles Quénot on Bash : Find and Remove duplicate files from...

They are dedicated tools to dedupe

View Article

Answer by Gilles Quénot for Bash : Find and Remove duplicate files from...

You need to use de-duplication dedicated tools, like jdupes:jdupes -d dir1 dir2You will be prompted for files to be removed.

View Article

Answer by Gilles Quénot for Removing Duplicate Files in Unix

You need to use de-duplication dedicated tools, like jdupes:jdupes -d dir1 dir2

View Article


Comment by Gilles Quénot on How to properly find and replace a multiline text...

-i is to edit the file, -O is paragraph mode

View Article


Answer by Gilles Quénot for Using sed to filter out students in a list

sed is not the most appropriate tool for this, better use awk like this : awk '$5=="A"{print $1, $2}' fileOutputBetty MettyEdit, filter 'engineering' string :awk '$5=="A" &&...

View Article

Answer by Gilles Quénot for How do I grep for a greater than symbol?

It's not the quotes : try this :grep -Ri -- '->someFunction' .the -- part, is a commonly accepted parameter in many modern utilities to denote the end of options, which is often important for...

View Article
Browsing latest articles
Browse All 65 View Live




Latest Images