I’ve been looking all over the internet but had no result. I’m trying to build a package generator (in shell/bash) and that respective package contains (one or more) json files. When browsing through a json file, if the user wants to delete one of the steps I must first take into consideration wha…
Tag: bash
Awk: How do I count occurrences of a string across columns and find the maximum across rows?
I have a problem with my bash script on Linux. My input looks like this: etc… which y=yes and n=no and that is the results of voting… and now I want with using awk to display the name and the total yes vote of each person (name) and the person that win (got the most y), any ideas? I do
ls command ignore specific directory [bash]
Tree: ls : Ignore specific file: ls -I c.txt : Ignore specific directory: ls -I Tests : (does not work – Tests directory should not appear) Answer The “man page” for the ls command explains that the -I flag accepts a pattern. So you can use a wildcard in your command: See: man ls or the comm…
reading from stdin after execl() bash return an eio(Input/output error)
The following code can act as expected if executed by a shell. But if I set this program as a user’s shell and ssh into the host to execute this program as a shell, the read(0, &buf123, 1); will return an EIO(Input/output error): But if a change execl(bash) into non-interactive bash execl(bash -c &#…
Close google chrome open in app mode via command line
In my python script I am opening chrome in app mode by this command: google-chrome –app=http://stackoverflow.com Now I want to be able to close only this running chrome application (I mean if there is another chrome windows with diffrent tabs I don’t want to close that, only this that i run). Is t…
Linux – Sort files by part of name (no delimiters)
I want to get a sorted list of files. Files have the following naming convention: DATENUMBER.txt (without spaces). E.g., file 3 on 2015-12-09 looks like: 201512093.txt The version sort option of ls doesn’t help me: sort -V, –key=1.[number] do not work too as I have different filename length. As I …
How to append a column for the result set in shell script
I need a script for the below scenario. I am very new to shell script. the above query results with following result Now I need to get result as follows: 1st column, 3rd column ,4th column of above result set and new column with default values Here the last column values is always known values i.e for file1 D…
shell script to read values from one file and replace it in other file
I would like to replace a set of strings into a new file. Source file file1.json values has to be replaced by values from file1.config into file file2.json. I have following script that is failing to do so. file1.json file1.config run.sh Error: file2.json appears, but it has no values replaced. Answer Just ex…
edit-and-execute-command bash with sublime text
In a bash terminal session, I notice that the edit-and-execute-command C-xC-e does not work with Sublime Text 3. I’ve set EDITOR=subl, but when I try to edit a command line from bash, sublime-text opens an empty window. Do I miss something ? Answer You should export the EDITOR as: as: To use Sublime Tex…
How does/frequent unix tee command write stdout terminal output to file? if the output is too big
I am redirecting some tool stdout to tee command so that current progress can be seen on terminal as well as in the log file Here is the code snippet where I am running tool and its stdout is fed to tee command and this code snippet is written from tcl script. I can see current real time progress on