Search for files in a git repository by extensions

I have a string like this *.{jpg,png} for example, but the string could also be just *.scss - in fact it is an editorconfig. Then I want to search for every file of this extension which is tracked by my git repository. I've tried several methods bu...
more »

2017-01-12 12:01 (1) Answers

Understanding exec in bash

After reading explanations of how the exec builtin works in bash, I understand that its basic function is to replace the current process without forking. It also seems to be used for redirecting I/O and closing file descriptors in the current proces...
more »

2017-01-12 01:01 (1) Answers

Linux "Locate" command and symbilic link

Does anyone know why "locate" command ignore symbolic links? Ex: lrwxrwxrwx 1 user user 6 Jan 17 2015 bin -> ../bin When I use locate to find file under this bin, it doesn't find anything. Command I used is = locate -ir '.*/bin/java$' ...
more »

2017-01-10 18:01 (0) Answers

Mass-renaming of files with double quote in name

I have a file system with a lot of files that I want to use on a Windows machine. Illegal characters in filenames are a problem, so I searched for a bash command which recursively sanitizes illegal characters from all files. I found this solution (h...
more »

2017-01-09 12:01 (1) Answers

Measuring peak disk use of a process

I am trying to benchmark a tool I'm developing in terms of time, memory, and disk use. I know /usr/bin/time gives me basically what I want for the first two, but for disk use I came to the conclusion I would have to roll my own bash script that perio...
more »

2017-01-08 13:01 (2) Answers

Bash function that breaks loop

I made a bash function that looks something like this: keystroke() { read -s -n1 -t0.1 key #Read a single keystroke for 0.1 seconds [ "$key" = $'\e' ] && #If the pressed key is escape { echo Aborted by user #Disp...
more »

2017-01-08 13:01 (1) Answers

Bash: Killing all processes in subprocess

In bash I can get the process ID (pid) of the last subprocess through the $! variable. I can then kill this subprocess before it finishes: (sleep 5) & pid=$! kill -9 $pid This works as advertised. If I now extend the subprocess with more comma...
more »

2017-01-06 16:01 (3) Answers

bash update file list of filenames with full path

I have a log file that looks like this: Jan 1 06:09:23 somefile.txt Jan 2 12:18:27 somefile1.txt Jan 3 04:16:00 somefile2.txt I would like to find each file and insert the full path of each file into this file. I would think there is some combi...
more »

2017-01-05 18:01 (2) Answers

how to output only when command finish

I'm running multiple commands using &: curl "url1" --output /dev/null 2>> out & curl "url1" --output /dev/null 2>> out & wait This doesn't work well because the output lines are interleaved. I want each curl to hold its out...
more »

2017-01-05 10:01 (1) Answers

BASH Syntax Checking Debug Mode Malfunction?

We can use bash -n script.sh to validate the syntax of a shell script. However, when I was trying to test this function, I noticed not all the syntax errors could be found by this option. For example: root@ubuntu:~/testenv# cat test #!/bin/bash S...
more »

2017-01-03 08:01 (1) Answers

Git using alias throws branch name required

I've tried to add a custom alias in git, but when I'm executing it, I get the error message: branch name required. I've executed this command for adding the alias: git config --global alias.dfrm 'branch --merged | egrep -v "(^\*|master|dev)" | xarg...
more »

2017-01-03 08:01 (0) Answers

grep array parameter of excluded files

I want to exclude some files from my grep command, for this I'm using parameter: --exclude=excluded_file.ext To make more easy to read I want to use a bash array with excluded files: EXCLUDED_FILES=("excluded_file.ext") Then pass ${EXCLUDED_FIL...
more »

2017-01-02 16:01 (5) Answers

get no. of lines printed for a date range

I am trying to get the count of no. of lines printed for a given date range. Here is my input and output: grep -inr "\[HSM \]Handle Identity Request. Send Identity Response. timeout: 1550s" *ActNac* ActNacd.txt:47:2017-01-02 09:10:13 - [HSM ]Handle...
more »

2017-01-02 14:01 (3) Answers

grep - limit number of files read

I have a directory with over 100,000 files. I want to know if the string "str1" exists as part of the content of any of these files. The command: grep -l 'str1' * takes too long as it reads all of the files. How can I ask grep to stop reading any...
more »

2016-12-30 21:12 (2) Answers

Remove lines with specific pattern with Bash

I have a file with one word/character for each line. Example: a abandonado esta estabelecimento o onibus c casa police I need remove lines with specific pattern (ex. pattern "esta"). I tried with awk cat file | awk '!/^esta/' but this solution...
more »

2016-12-30 18:12 (4) Answers

Use Sublime Text as a core editor of Git Bash

I'm following a novice guide for Git and Github, but I'm having problems to connect Git Bash with Sublime Text. I'm using Windows 10 and to use Git I have installed Git Bash. Once I installed this, I created an alias like this: echo 'alias subl="C:...
more »

2016-12-30 17:12 (0) Answers