I’m trying to calculate a sum numbers positioned on separate lines using C shell. I must do it with specific commands using pipes. There is a number of commands: comand.. | comand.. | (comands…) printing lines in the following form: The result should be 22, since 1 + 2 + 8 + 4 + 7 = 22. I tried &#…
Tag: shell
Zenity command for multiple file filtering
I tried some Zenity command for file filtering in my java program. and But these are not worked properly . insted of giving the all filtered file it only give the first file type given in the comment ,thant means; in these, it given back only the .gif file as the output) . Answer Could you try something like …
qt run shell commands via qprocess
I am developing a small QT application to interact with the terminal, to send commands to the terminal and to read back information printed out. Example: get output of all processes using ps -aux PROBLEM I am able to write information out to the terminal but I dont think it is in the system scope, actual exam…
Converting date format in bash
I have similar different file of the format backup_2016-26-10_16-30-00 is it possible to rename using bash script to backup_26-10-2016_16:30:00 for all files. Kindly suggest some method to fix this. Original file: backup_2016-30-10_12-00-00 Expected output: backup_30-10-2016_12:00:00 Answer To perform only th…
Move all files at one level up one level
I had a problem with a backup on a linux server that somehow moved all folders of files down one level into a new folder with the same name. I would like to return all files to their original location. Many of the files have spaces in their names to complicate things. Original directory structure: Incorrect d…
Word count after zgrep
I’m a little confused as to what this counts: Does it count the occurences of abcd in the 4 lines xyz? “wc -l” returns a different count than the number of lines present inside the file. Answer Prints every ‘xyz’ and 4 lines before from the file. zgrep -B 4 “xyz” <…
cURL empty request data if https connection
I try to send the file via POST. Before that i used http connection and everything worked. But now var_dump($_REQUEST); in my php-file returns an empty array. This my curl log: $ curl -X POST -F “id=1” -F “file=@/tmp/file.txt” https://MY_DOMAIN/save_file.php -v Hostname was NOT found i…
Isn’t it possible for a file to not be visible for other processes?
I have a Java application which is invoked from a shell script and creates a file, then writes some content to it. It works something like this: The resulting file will be quite large (up to 100MB). The issue is that opening the FileOutputStream creates an empty file and makes it available to other processes …
Linux – Do a command repeatedly for a certain length of time
I know what the command watch -n does. I would like to do something like the following: Essentially I want to repeat a command every 5 seconds, then stop after 30 minutes has passed. I’m missing the stop 30 minutes part. What command should I use to achieve this? Thanks. Answer Use timeout:
Ifconfig and route command on Android
I wondering whether exist way to get result of ifconfig and route commands result programmatically in Android device? Can I do this in non rooted device? Answer In your AndroidManifest.xml file Your code: Output You can’t reach to know whether you are connected via wifi or network using WifiManager as W…