Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

5

I'm assuming stat being "too verbose" means the command outputs a lot of other information too, which it does by default if you don't request specific bits of info from it. With GNU stat: stat --printf '%y\t%n\n' -- *file* That would output only the modification timestamp in human-readable format followed by a tab and the filename. This will be done on ...


2

First, you don't need cat with grep. That is enough: x="$(grep ConfigPath /scratch/env.properties)" Second, I believe this is not an assignment you want: y=$(ConfigPath=/scratch/a/b) If you want variable y to hold ConfigPath=/scratch/a/b string it should be: y="ConfigPath=/scratch/a/b" $(...) is a command substitution in Bash. Third, you should use ...


2

grep is already a really fast way to go through big files and find words or characters in lines, maybe the -w word-regexp makes it a bit slow. Often it is not the grep itself which is slow, it is mostly the output on the terminal. You can simply test it by direct the output to a file: grep -w "for-outbound-sports\|2019-05-16" Master.csv > greped_master....


2

Assuming all of your numbers are, as shown in the examples, fixed-point decimal: Using grep $ grep -E '(Thispeculiarpattern|Somerandomtext|Herewegoyetagain)\(([1-9]|0\.[89])' file Thispeculiarpattern(1.00);thatpeculiarpattern(0.90);.... Somerandomtext(0.81); somemorerandomtext(0.79):................................. Herewegoagain(0.71);Herewegoyetagain(0....


2

The package of grep 3.3 is for the edge release, i.e. the development branch of Alpine Linux. Release 3.9, which you’re using, has grep 3.1. If you really want it on your 3.9 system, you could always rebuild it by downloading the relevant package source and running abuild as appropriate.


1

_ (underscore) is a valid character in a variable's name. This means that $file_output.txt uses the variable file_output and appends the string .txt to its value. If that variable does not exist, then you now have a file called .txt. To tell the shell that the variable name ends before the _, use curly braces around its name: "${file}_output.txt" Also ...


1

The idea is quite right, but the negation operator to use along with the && is in wrong place altogether, it needs to be alongside the test operator. With your command in question the first part of the if condition is evaluated as below, grep -qs "$mount" /proc/mount ! in which the negation operator is treated as an another file to search on by ...


1

The following script works for me #!/bin/bash if [ -r .grepignore ]; then while read -r line; do if [[ "$line" =~ '#' ]] || [[ "$line" =~ ^$ ]]; then continue fi EXCLUDE="$EXCLUDE --exclude-dir=\"$line\"" done < .grepignore fi eval grep -r "$EXCLUDE" '"$@"' The script checks whether a file .grepignore exists ...


1

Pipe your input through sed 's/][^[]*\[/,/g;s/\([^,]*,\)\{3\}//;s/ *,/,/;s/]$//' s/][^[]*\[/,/g does most of the job by removing everything between the [] and separating it with comma s/\([^,]*,\)\{3\}// gets rid of the first fields you don't use s/ *,/,/ strips the obsolete spaces s/]$//' finally removes the last ] Update: Your comment suggests, that ...


Only top voted, non community-wiki answers of a minimum length are eligible