Skip to content

Tag: bash

bash how to get async command output to variable

i want to know how can we get command output to variable in bash here is my code output not working inside function šŸ™ Answer Please try redirecting stderr to stdout like: Here you can read more about command substition.

Linux shell change directory,file not found

I have written my convert.sh shell This is my working directory All executables and libraries are here, including tsmp. But when I run my script It seems that I do not understand alias. Following chepner’s comments,I have tried this But Why? Answer tsmp is not in your PATH environment variable, so you h…

Copy bulk files to another destination using a given prefix in bash

I want to copy all the files newer than another one from their original location /lib/ into another destination /dest/lib/ To identify these files I simply use: Unfortunately I cannot simply use this command because cp does not know how to create folders on the fly. So I used this command: This looks very com…

Linux – flip last bottom lines only, with awk

We are currently learning some awk commands to manipulate/rearrange text on files. our original text goes like this..1998 It’s asking us to rearrange the columns (part one) which i already did.. but at the same time to flip the bottom two lines (part two) so that it looks like this again, i got the orde…

How to clear terminal window after TMOUT

I want to see if there is a way to have the terminal windows cleared after a TMOUT session timeout and disconnect. Does anyone know of a way to have the screen cleared once it times out? Answer Set an exit trap in your .bashrc file When the shell exits, it executes the clear command if TMOUT is set to

Cannot pass STDIN using shell_exec() in PHP

I am a complete beginner in PHP. I want to execute a java .jar file using PHP.The jar file takes input from STDIN and generates the output at STDOUT.To execute the jar file this is what I do in my Ubuntu Linux terminal: This works perfect.However when I replicate this in PHP as: This sends $p the output gener…

Reading corrupt file, segmentation fault

I run my program by passing it a bunch of directories like this: Each directory is a separate set of files that I am parsing for data which I then create into a spreadsheet. Each directory is a different row of the spreadsheet. I want to only put reliable data in the spreadsheet and so if an entry is missing

Debian Startup Script Will Not Start

I was creating a startup BASH script, when I was given an error similar to: So I went and put in some LSB tags, but it still does not start on startup. The script works perfectly if I start it manually It is a very simple script that is intended to startup a PERL script in the same folder (/etc/init.d/fcgiwra…

Split lines from a file into variables (accepting spaces) BASH

I need a script in bash that reads a file and recognize an delimiter (“;”) and store the values between the delimiters into variables to build a dialog menu later. What i’ve done: the file that it reads is : And the output: Answer With a while you can split a line into a lot of vars in 1 cal…