Skip to content

Tag: bash

Possible to read the last line of a linux gnu-screen?

I’m trying to make a simple and reliable script, preferably in bash, that is executed every minute using crontab. The script simply has to read the contents of the last couple of lines of an open screen and store them as a var so that I can search for a sub-string. Does anyone know of an easy way to do

Bash alias cpu usage

I’ve tried this command but I have a percentage error calculator: Thank you for help Answer Change it to this: was missing after 100 -.

how to output only when command finish

I’m running multiple commands using &: This doesn’t work well because the output lines are interleaved. I want each curl to hold its output, until it’s done. How to do that? I understand I can use temp files, concat together and delete afterwards. Are there better ways? Answer You could …

Convert Binary Strings (ASCII) to Binary File

I have several large files (3-6 Gb) of 1’s and 0’s characters in ASCII and I would like to convert it to a simply binary file. Newlines are not important and should be discarded. test.bin below is 568 bytes, I would like the 560 bit file. I’ve found several solutions going the other way, con…

Should I be using parameters or export environment variables?

I’ve always developed my shell scripts using parameters, on a daily-basis or even when developing some automation scripts. However, recently I’ve tried a different approach, exporting environment variables to my scripts. This ensures a smaller code, easy checks if all the required variables are in…

Bash : Configuring email-provider for bash-script

I am working on writing a script to run on our Debian server(Debian 3.2.68-1+deb7u5 x86_64 GNU/Linux), which will monitor a specific port we have and when there is no process running on that port, or that port is available, then I will have to send out an email. I intend to run the script every 15 minutes and…

Bash replacing text in file

I want to automate changes in a File. For example ;max_input_vars = to max_input_vars = 10000 in /etc/php5/cli/php.ini with a script. How can I do that? I know command sed will do something like that. Answer Try this command: