Calculate statistic using awk

I have a question regarding to my previous successfully answered question here by @fedorgui. I have a table: pac1 xxx pac1 yyy pac1 zzz pac2 xxx pac2 uuu pac3 zzz pac3 uuu pac4 zzz And I need to calculate output like this: pac1 xxx 2/4 pac1 yy...
more »

2017-06-20 18:06 (1) Answers

Calculate disk peak size in Linux

I need to benchmark tools in terms of their maximum(peak) disk use.We have observed that tool creates temporary files on disk. So, I want to figure out how much peak disk space it utilizes (bytes written) for storing temporary files during its execut...
more »

2017-06-20 17:06 (1) Answers

Check correct columns in bash

I have a lot of files and I would like to test, if file is valid, then keep it else delete it. Valid file may looks like: cat in.tsv LRG_293 het rs144848 c.1114A>C 1 LRG_293 het rs1799943 c.-26G>A 1 LRG_293 hom rs1799955 c.7242A>G 6 LRG_...
more »

2017-06-19 14:06 (4) Answers

BASH script to switch between PI modes

I'm trying to create a BASH script for my Pi3 along with a desktop icon that will change the amount of gpu_mem allocated and rename the icon to the mode that is not in use. #!/bin/bash s1=$(grep gpu_mem /boot/config.txt) s2="gpu_mem=156" if [ "$s1...
more »

2017-06-19 11:06 (1) Answers

Bash get exit code of a waiting process

I would like to get an exit code of a process i am waiting for and return it. I have a script called script.sh that looks like that: #!/bin/bash path="/PATH/TO/SCRIPT/another_script.sh" $path wait cleanUpFunction How can I return from script.sh t...
more »

2017-06-18 17:06 (1) Answers

How to simulate hung task in linux?

I just changed following configurations in /etc/sysctl.conf : # Reboot 5 seconds after panic kernel.panic = 5 # Panic if a hung task was found kernel.hung_task_panic = 1 # Setup timeout for hung task to 300 seconds kernel.hung_task_timeout_secs = ...
more »

2017-06-18 07:06 (1) Answers

How to use brace expansion in gitrevisions <text>

Using GNU Bash 4.3 and Git 2.1.4, I encountered difficulty using brace expansion with gitrevisions syntax. Specifically, I want to get the Git commit IDs for some specific commit messages. Here is the log: $ git log --format=oneline 924d9120dec9f6...
more »

2017-06-17 22:06 (1) Answers

How to replace string in a file

I am writing shell script which will list the drivers .ko files and adding entry in init file. File comes in initramfs. so below some thing i have did in script, I tried google but solutions not working so finally i had to post question. few issues...
more »

2017-06-16 14:06 (1) Answers

What the best way to delete files by extension?

I am looking the best way to delete files from directory by extension. I am planning to do it by date. But now, i am testing how it works. This: dir=/tmp/backup/ mask="jpeg jpg png gif bmp pdf" for i in $mask; do find $dir -name "*.$i" -type f -de...
more »

2017-06-15 16:06 (1) Answers

how to do if statements with "and" in sh

I try to solve this problem with the sh and not the bash. All i want is a if statement that check some regex AND something else. Normally in bash this would be an easy job but with the sh i only find solutions online that wont work for me First thin...
more »

2017-06-15 15:06 (3) Answers

Iterating over command-line argument pairs

I have a more than 400 coordinates that I want to pass as an argument into a string, but i don't know how to pass the first argument as "lat" and second argument as "lng" and so on for the rest. Say I was passing in this ./test 1 2 3 4 I want my...
more »

2017-06-14 22:06 (3) Answers

Iterate over $PATH variable using shell script

If I type echo $PATH in the terminal I get the following result: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/fnorbert/.local/bin:/home/fnorbert/bin I want to iterate over these paths using a shell script, but I do not know how to do th...
more »

2017-06-13 16:06 (5) Answers

sed replace group of files string

I am trying to replace a string in multiple lines. It is late and I'm getting restless, maybe someone would prefer to give it a shot for some SO points. The string I'm replacing is 'STORED AS TEXTFILE' from the SQL below... PARTITIONED BY(load str...
more »

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

Bash script to kill Port

At the moment I am learning SSH creating and listening of servers. But I still tend to do it wrong a lot and afterwards my Ports are still open. So I am writing a bash script to kill it, but I had a bug I was unable to solve... So any help is welcome...
more »

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

Run a script if no SSH connection

I'm trying to get a script to run at startup, but does nothing if I've connected to my Raspberry Pi via SSH. So far I've got the crontab to automatically run the script checkssh.sh via @reboot sleep 30 && sudo bash ./checkssh.sh and './chec...
more »

2017-06-11 13:06 (2) Answers

Git Bash cant run commands after running subl

So I run $ subl and sublime opens, but then my command line goes blank, or infinite, not sure what its called. example $ subl | I can type anything i want hit enter, goes to next line and so forth but nothing will actually happen until i close s...
more »

2017-06-11 04:06 (1) Answers

Remove whole line based value of the last field

If I find any value from 64512 to 65535 at the last field, then the whole line will be removed: sample data: 20170101|1.0.136.0/24|2497 38040 28969 20170101|1.0.137.0/24|2497 38040 33423 20170101|1.0.138.0/24|2497 38040 64603 20170101|1.0.139.0/24|...
more »

2017-06-10 19:06 (4) Answers

How to "inject" lines into a here doc redirect?

I have a BASH function execute that establishes a connection over SSH to a machine and executes a bunch of commands provided via here doc redirect. That works great. Is there a way to inject some commands into the redirect? I would like to run always...
more »

2017-06-09 17:06 (1) Answers