How To Delete All Words After X Characters

I read this post: sed delete remaining characters in line except first 5 which helps me to delete all characters after x. However, I'm having a hard time finding how to delete all words after x characters. I started with this code: echo "StackOverf...
more »

2017-10-14 18:10 (5) Answers

STDOUT of nested commands in Bash

Quite new to bash - I'm trying to store the output of my /usr/bin/time command into the TIME_INFO variable, which works with the below setup... however I would also like to be able to store the output of some of the other nested commands (such as /us...
more »

2017-10-14 17:10 (1) Answers

Grep resource usage

I have been tasked with writing a shell script to grep through hundreds of log files in many directories on Linux and Solaris servers. Some of the logs are compressed in many formats and some are a few GB in size. I am worried about grep using a lot ...
more »

2017-10-12 20:10 (1) Answers

curl with json array

The first command works and the second doesn't. What do I need to change to allow the json array to work? Thank you in advance. command #1: curl -d '{"uid":"TEST", "object":"TEST"}' \ -H "Content-Type: application/json" \ -X POST ...
more »

2017-10-12 19:10 (1) Answers

Using sed and awk to edit lines in a file

I have a file of a few host names separated by spaces then a location. host1 C1U5 host2 C11U55 host15 C5U10 I have to edit the file of hosts. I have written the sed/awk lines to remove characters but my sed lines just returns the full line. I...
more »

2017-10-11 22:10 (5) Answers

Git autocomplete for custom bash functions

In my .bash_profile, I have a lot of functional shortcuts for git. For example: function gitpull() { branch="$1" if [[ -z $branch ]]; then current_branch=`git symbolic-ref -q --short HEAD` git pull origin $current_branch; ...
more »

2017-10-11 21:10 (1) Answers

For loop for result of "find" command

I have this find command: $ find . -name '*.jar' -exec grep -Hls BuildConfig {} \; I need to execute this command for each result of command find above: $ zip -d RESULTPATH "*/BuildConfig.class" So can I do this with for loop or not? Can I crea...
more »

2017-10-11 19:10 (2) Answers

BASH: show find all files but not last 2 newest

I have a list of files one time list can contain: 1489247450-filename1 1489248450-filename2 1489249450-filename3 1489249550-filename4 and another time: 1489249450-filename3 1489249550-filename4 and another time: 1489245450-filename1 1489246450...
more »

2017-10-11 18:10 (2) Answers

Bash JSON string into variable

my idea is to put json string into variable JSON, i have a command whom takes a console login to user in AWS IAM, the comand is : aws iam create-login-profile --cli-input-json file://create-login-profile.json in create-login-profile.json is the jso...
more »

2017-10-11 14:10 (1) Answers

Remove Words Shorter Than 4 Characters Using Linux

I have read the following and tried to rework the command logic for what I want. But, I just haven't been able to get it right. Delete the word whose length is less than 2 in bash Tried: echo $example | sed -e 's/ [a-zA-Z0-9]\{4\} / /g' Remove all...
more »

2017-10-10 21:10 (3) Answers

Bash - Rename file that have " in it

Ok I have a function that will have as parameter a string and it will output a new string that doesn't have any spaces, ', " function rename_file() { local string_to_change=$1 local length=${#string_to_change} local i=0 local new_string=" " loc...
more »

2017-10-10 18:10 (1) Answers

Permanently add an SSH key

To get access to my remote git I add a reference to the SSH every time I push or pull: GIT_SSH_COMMAND="ssh -i ~/.ssh/id_bit_rsa" git pull origin master Is there a way to have the git remember the SSH so I don't need to add it each time? ...
more »

2017-10-10 10:10 (3) Answers

Interpreting gfortran error traceback

I'm running a Fortran 77 program written by someone else. I'm using the gfortran compiler (v5.4.0) on Linux (Ubuntu v.16.04). I'm not an experienced user of Fortran, gcc or bash scripting, so I'm struggling here. When my program finishes running, I ...
more »

2017-10-10 02:10 (1) Answers

Parse VCF file's INFO field

Please help me parse a VCF file. I am pasting a real example. Input: 1 1014143 rs786201005 C T . . RS=786201005;RSPOS=1014143;dbSNPBuildID=144;SSR=0;SAO=1;VP=0x050068000605000002110100;GENEINFO=ISG15:9636;WGT=1;VC=SNV;PM;PMC;NSN;REF;ASP;L...
more »

2017-10-08 16:10 (3) Answers

Bash: basename inconsistency when run in find

Whole story: I am writing the script that will link all files from one directory to another. New file name will contain an original directory name. I use find at this moment with -execdir option. This is how I want to use it: ./ 201...
more »

2017-10-08 11:10 (1) Answers

Changing colours in whiptail

Is there any way to change particular colour in whiptail ? For example to mark specific text in red ? For example : #!/bin/bash window=$(stty -a | tr \; \\012 |egrep 'rows|columns' | cut '-d ' -f3) RED="red" GREEN="green" OPTION=$(whiptail --me...
more »

2017-10-07 13:10 (1) Answers