FAQ Database Discussion Community


Converting values from for loop to json format

linux,unix
Below is a snippet of a for loop where I sort txt file names. I am then trying to save the results in a json format file. However it results in an invalid json format due to the last , inserted in obj. How could i convert to json format...

Applying chmod 755 (or other) when ftping to apache var/www/ virtual host directories?

linux,apache,chmod
I'm struggling to understand how to apply directory and file permissions so that files and directories created by the ftp user, via an ftp client, are browsable. In other words 755 is applied by default. I'm running Apache 2 on Ubuntu 14.04.2 LTS, Trusty Tahr, with vsftpd server. My directory...

How to extract single-/multiline regex-matching items from an unpredictably formatted file and put each one in a single line into output file?

linux,shell,unix,replace,grep
I have a very huge file which looks like this: <a>text</a>text blah <b>data1</b>abc<b>data2</b> <b>data3</b>blahblah <c>text</c> <d>text</d> <x>blahblah<b>data4 data5 data6</b> <b>data7 </x> That is, its formatting is unpredictable. I need to extract each <b>...</b> item (it might contain multiline text!) and put every one of them in a single separate line....

PHP `require_once` includes wrong file

php,linux,ext4
I have a development tree on a Linux Ubuntu 14.04-LTS machine like this, with three identical branches: main -+-- leonardo --- project --- htdocs -+- panel --- index.php | | | +- config.php | +-- federico --- project --- htdocs -+- panel --- index.php | | | +- config.php |...

Linux-wget command

linux,shell,wget
I need a quick help on customizing my wget command in a shell script: The wget command looks something like this: wget http://infamvn:8081/nexus/content/groups/LDM_REPO_LIN64/com/infa/com.infa. products.ldm.ingestion.server.scala/10.0.0.135.527-SNAPSHOT/com.infa.products.ldm.ingestion.server.scala-10.0.0.135.527-20150622.210643-1-sources.jar Here I'd like to add the 10.0.0.135.527 in a variable, so I created a script something like this: n = 10.0.0.135.527 wget...

Problems with filename encoding on Linux when created through Java

java,linux,encoding
I'm having a problem, and I've been stuck with it for quite some time now. The problem is, I can't get file names to support special characters (only file names, file content is ok). Instead of them, file name is created with question marks. Now, from what I know (and...

Slimerjs with exec linux centos 6

php,linux,exec,slimerjs
I just installed Slimerjs and no results on the web. the slimerjs is found and commands like -help etc output like they should: exec('/usr/bin/slimerjs -help'.' 2>&1',$out,$ret); but this line does not work exec('/usr/bin/slimerjs /var/www/html/capture.js'.' 2>&1',$out,$ret); var_dump($ret, $out); outputs only int(1); and nothing more. no errors in logs, it does not...

Using an ad-hoc libc with a tool which is an argument of another tool

linux,shared-libraries
I need to use a particular libc to run a tool (cp). The problem is that this tool has to be used as argument of another tool (for example timeout) and I don't want to use the modified libc with this one. I tried to do: timeout 10 LD_LIBRARY_PATH=/path/to/mod/libc/ cp...

How to do the expansion of variable in shell script? [duplicate]

linux,bash,shell,unix,ksh
This question already has an answer here: Bash expand variable in a variable 4 answers I hava a column in database which contains the following data: sql_proc|test_sql.sql|/home/Desktop/myfile.txt|$IMP_FILES/myFolder|convert I have fetched this into a variable and I have used the cut command with "|" as delimiter and saved each field...

How could I simulate a lack of file descriptor?

c,linux,file-descriptor
I would like to provoke a situation where there is no file descriptor remaining. I have been thinking about 2 possibilities: Opening thousands of files randomly until the result of open is -1 Set a very low number of file descriptor available (let's say stdin, stdout and stderr). How would...

How to schedule an R Script Cronjob in a linux server? [closed]

linux,r,cron,crontab
I am trying to schedule a cronjob to execute an R Script in a linux server. I have achieved to type the commands in the server manually and it works. To do so i have to type the following commands: [email protected]:~# cd /home/script2 [email protected]:/home/script2# Rscript scriptSecos.R How can i specify...

While loop in bash using variable from txt file

linux,bash,rhel
I am new to bash and writing a script to read variables that is stored on each line of a text file (there are thousands of these variables). So I tried to write a script that would read the lines and automatically output the solution to the screen and save...

Is it possible to run command “route -n” specifically for a NIC

linux,shell,scripting
I am fairly new to linux I wanted to ask if its possible in linux commands to run a "route -n" command to retrieve information for a specific NIC. E.G route -n ether0. Because currently it shows me for all the NIC's but what if I want just for one?...

Bash script for basic mathematic operations

linux,bash,math
I am new to Linux, and I just want a Bash Script to do basic arithmetic operation to a text file 1 2 3 4 and the results should be addition and multiplication in separate text files say add + 5 for 1st text file and mult * 5 in...

Debugin UDI program by gdb

linux,gdb
The program from below asks user for his name, greetings him and then gives us his real ID. We could assume that in case of 16-letter name (or longer) the uid variable will be overwritten and the program gives us incorrect user ID. But it isn't. How to explain this...

Django MySQLClient pip compile failure on Linux

python,linux,django,gcc,pip
Django documentation as of v1.8 recommends using mysqlclient connector for the framework. I'm attempting to pip install the package on Ubuntu 14.04 with Python 3.4 and running into a GCC error that I'm unable to find reference to. I'm not an expert on compiling software, so was hoping somebody can...

shell script to shutdown/restart Linux system

linux,shell
Is there any suitable shell script for shutting down or restarting a Linux machine? I have tried a shell script for shutdown, but when I enter sudo shutdown it will ask for the password. How we can enter the password using the script?

Shell script to loop over files with same names but different extensions

linux,bash,shell
For example say I have: filename1.ext1 filename1.ext2 filename2.ext1 filename2.ext2 I need to write a shell script to feed these files into a program like so: program filename1.ext1 filename1.ext2 program filename2.ext1 filename2.ext2 Additionally the .ext1 files must be entered first and the .ext2 files second. Any help would be appreciated....

Python Thread Breaking Terminal

python,linux
Hello minds of stackoverflow, I've run into a perplexing bug. I have a python script that creates a new thread that ssh's into a remote machine and starts a process. However, this process does not return on its own (and I want it to keep running throughout the duration of...

Windows/Linux child process STDIN differences

linux,windows,perl,process,stdin
I built a simple text processing script at work to be used by another program. When I was done, someone remembered that the script needs to not block STDIN/STDOUT for the tool using it to work right, and modified the script accordingly. The script opens *nix's cat in a subprocess...

Delete some lines from text using Linux command

linux,shell,sed,grep,pattern-matching
I know how to match text using regex patterns but not how to manipulate them. I have used grep to match and extract lines from a text file, but I want to remove those lines from the text. How can I achieve this without having to write a python or...

how to determine directory or file in linux in c

c,linux
I want to print only file names without printing Directory Names. So, I implement this function void list_file(char* directory){ DIR *d; struct dirent *dir; d = opendir(directory); if (d) { while ((dir = readdir(d)) != NULL) { printf("%c", dir->d_name[(int)strlen(dir->d_name)]); if(dir->d_name[(int)strlen(dir->d_name)-2] != '/') printf("%s\n", dir->d_name); } closedir(d); } } I checked...

What are correct permissions for Linux Apache2 PHP 5.3 log file?

php,linux,apache,logging,permissions
I discovered the reason why I was not getting entries into my php_errors.log file related to permissions. Right now, I have set it to 666 (rw-rw-rw-) but surely this is a security weakness? Thus, my question. php.ini file: error_log /var/log/httpd/php_errors.log log_errors On # ls -ld /var/log /var/log/httpd /var/log/httpd/php_errors.log drwxr-xr-x 6...

Linux/shell - Remove all (sub)subfolders from a directory except one

linux,delete,find,folder,rm
I've inherited a structure like the below, a result of years of spaghetti code... gallery ├── 1 │   ├── deleteme1 │   ├── deleteme2 │   ├── deleteme3 │   └── full │   ├── file1 │   ├── file2 │   └── file3 ├── 2 │   ├── deleteme1 │   ├── deleteme2 │   ├── deleteme3 │  ...

Extra backslash when storing grep in a value

linux,bash
In a bash script I have: Check="grep -e '"'\(-S mount\)'"' /etc/audit/audit.rules" set -x When you run it it shows it as: CHECK='grep -e '\''\(-S mount\)'\'' /etc/audit/audit.rules' Now it works exactly what I want but I want to understand it. Why is there 2 extra \'s?...

Get system startup time (without reading /proc/uptime)

php,linux
I cannot open /proc/uptime due to open_basedir restriction. The command uptime is too old and doesn't have the -s flag support. How can I - in PHP - get time when the server started? My current code is this, but it does not work on the production server (for the...

AWK count number of times a term appear with respect to other columns

linux,shell,command-line,awk,sed
Given a CSV file: id, fruit, binary 1, apple, 1 2, orange, 0 3, pear, 1 4, apple, 0 5, peach, 0 6, apple, 1 How can i calculate for each unique values in fruit, the number of times the binary value =1 / number of occurences of that fruit...

fread(), solaris to unix portability and use of uninitialised values

c,linux,memory,stack,portability
Valgrind found the following error and I, after reading the documentation, the code and other questions in here couldn't figure it out why. Valgrind: first warning ~$ valgrind --vgdb=yes --vgdb-error=0 --read-var-info=yes --leak-check=yes --track-origins=yes debitadmin* debitadmin ==20720== Conditional jump or move depends on uninitialised value(s) ==20720== at 0x4013BC6: initialise (dbg.c:199) ==20720==...

Redirect stdout using exec in subscript

linux,bash,redirect,command-line,sh
I have one main script which is started as an service. I can't modify this main script, because it is often updated. This main script starts a program, which echo any log to stdout. So i can't see any log of this program. But this main script calls at the...

Java read bytes from Socket on Linux

linux,windows,sockets,network-programming,raspberry-pi
I'm trying to send a file from my Windows machine to my Raspberry-Pi 2, and I have a client and a server. The client should be able to send a zip file over the network to my server on my linux machine. I know my client and server work on...

NASM: copying a pointer from a register to a buffer in .data

linux,assembly,nasm,x86-64
I am new to asm. I am trying to copy a pointer from a register to a .data variable using NASM, on linux 64-bit. Concider this program: section .data ptr: dq 0 section .text global _start _start: mov [ptr], rsp mov rax, 60 mov rdi, 0 syscall Here I try...

ERROR 1130 (HY000) or ERROR 2003 (HY000) : connect mysql from windows to ubuntu on VMware

mysql,linux
I tried many ways but failed.I want to connect the MySQL on Linux in VMware from Windows. VMware:11.1.0 build-2496824 Linux:Ubuntu 14.10 Windows:win 8.1 x64 MySQL Version windws: 5.6.24 Linux: 5.5.43 IP Windows:192.168.1.102 Linux: 192.168.1.100 PS: Ping requests receive packets from each other. When I input the cmd: mysql -h 192.168.1.100...

how to modify an array value with given index?

arrays,linux,bash
I want to modify an array cell, which I can do when I know the cell as a number. However here my cell position is given by $i. pomme[`${i}`]="" I tried without the `` and it doesn't work either? How am I suppose to do it?...

Are the C functions recvfrom and sendto mutually exclusive?

c,linux,sockets,udp,thread-safety
I have one thread calling recvfrom with a timeout of 100 ms in a loop. Another thread calls sendto periodically. Does the sendto function wait until the recvfrom is released by the timeout (or a successful read) or does it send the data during that period of time....

Pipe ffmpeg output to named pipe

linux,ffmpeg,named-pipes
I'm trying to get ffmpegs output to a named pipe, where I could read from another shell. I do not need the video stream piped, just the informations below to get a state of the conversion process back. I am not able to achieve the piping behavior in any way,...

How to replace newlines/linebreaks with a single space, but only if they are inside of start/end regexes?

regex,linux,shell,unix,replace
I have an extremely big (many GBs in size) file that looks like [x data1 data2 data3 data4 y] [a data5 data 6 data7 data 8 b> [x data y] ...and so on How to replace newlines (which might be surrounded by spaces) with a single space, but only if...

How can I resolve the “Could not fix timestamps in …” “…Error: The requested feature is not implemented.”

linux,build,f#
I have been trying to build a project in F# on Linux that I have located here on github. It's a basic kata project that I am working on as a demo. However on Linux (specifically Ubuntu 14.04 LTS Desktop) I haven't been able to get it to build yet...

C: Linux to Windows: Sending text file over TCP produces not exact copy on the Windows side

c,linux,windows,sockets,tcp
I'm writing a system to gather software/hardware info on Macs to put it into a Windows-based SQLite3 database. Schema is as following: agent on Mac - gather data, then sends it over Internet, using SSL, to small Linux server in DMZ (this part works as intended so far) Linux server...

launch several scripts located in subdirectories

linux,bash,shell
Here is my problem. I have a directory that contains multiple sub-directories. In each sub-directory, there is at least one script sh. I want to do a script that execute sequentially all this scripts. I am pretty new to linux. Thanks for your help, ...

Bash modify CSV to change a field

linux,bash,awk
I have a very big CSV file (aprox. 10.000 rows and 400 columns) and I need to modify certain columns (like 15, 156, 220) to change format from 20140321132233 to 2014-03-21 13:22:33. All fields that I need to modify are datetime. I saw some examples using awk but for math...

Linux: Using split on limited space

linux,bash,file-io
I have a huge file on a linux machine. The file is ~20GB and the space on my box is ~25GB. I want to split the file into ~100mb parts. I know theres a 'split' command but that keeps the original file. I don't have enough space to keep the...

Linux - sh script - download multiple files from FTP

linux,ftp,sh
I need script that can download files from ftp via my sh code I have use expect with ftp, but if I do for loop inside code, I got wrong # args: should be "for start test next command" while executing "for v in "a b c"" My code /usr/bin/expect...

cat /dev/null to multiple files to clear existing files like logs

linux,bash,shell,command-line,tee
A good way to clear logs(syslog has a handle on file) which have frozen my linux server(out of space) I tried cat /dev/null > fileABC; cat /dev/null/ > fileXYZ How can I clear multiple files by cat /dev/null to multiple files in an efficient or single command. ...

Ignore first few lines and last few lines in a file Linux

linux,awk
I have a file like this and would like to print $0 except the first two and last three lines in linux. Tried awk command but no luck, is there any options I am using the following command - I suppose I am doing something wrong, but not able to...

AH01630: client denied by server configuration Apache

linux,apache,.htaccess,prestashop,prestashop-1.6
I get this error when trying to access localhost via a browser. 403 Forbidden I use Ubuntu 14.04 LTS Here is my configuration file: etc/apache2.conf # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See http://httpd.apache.org/docs/2.4/ for...

Am I using z3 :timeout correctly with C++ interface for Linux?

c++,linux,z3
I'm trying to get the z3 solver to timeout after 0.1s on this example (factoring a 32-bit product of two primes), using the C++ interface. It works on Windows (VC++ 2013), but not on Linux (CentOS 6.5), where the solver runs to completion in around 2.5s (debug build). This post...

Set label on group multiplot in gnuplot

linux,graph,plot,gnuplot
Im plotting one picture with 4 different graphs using gnuplot. Labels for their x and y axes have the same meaning. If Im plotting it like this: set multiplot layout 2,2 rowsfirst set xlabel "x" set ylabel "y" set title offset -3,-3 set xrange [20:70] set yrange [0:15000] set title...

Change a Script to a For Do Done Loop

linux,bash,for-loop,awk
I have a script that I need to turn into a loop, the script works exactly as I need it to (My Awk-fu is extremely weak, so be nice) when I put in the file name like the example below. #!/bin/bash awk -v FS='(<LastName>|<\/LastName>)' '{print $2}' 17822624.xml >> test.csv awk...

Syncing Vagrant VMs across different physical servers

linux,vagrant,backup,virtual-machine,sync
I'm using Vagrant to deploy my VMs and my current setup looks like this: server1 = VM1, VM2, VM3 ( main production server ) server2 = VM1, VM2, VM3 ( backup server ) My questions is, can I somehow sync the VMs across the different physical servers in case one...

Haskell make recipe fails for Paradox theorem prover using GHC

linux,haskell,make,ghc,theorem-proving
I am trying to install the paradox theorem prover sourced from here. When I run the makefile this is the command that runs: ghc -optl -static -lstdc++ -I../instantiate -I../minisat/current-base ../minisat/current-base/Solver.or ../minisat/current-base/Prop.or ../instantiate/MiniSatWrapper.or ../instantiate/MiniSatInstantiateClause.or -fglasgow-exts -O2 -static -threaded -main-is Paradox.Main.main --make Paradox.Main -o paradox And it results in several errors like...

run python script with arguments on a remote linux host

python,linux,ssh
I have this python script that I'm trying to run on a remote host. However, the script requires two arguments. For example, python script.py --port 4000 --service status Now when I run the script locally on the machine it works fine. How can I run this same script on a...

What is the difference between `./example.sh` and `sh example.sh`

linux,bash,shell
I am trying to play with bash and arrays. But executing a sample script, I got an unexpected syntax error message: example.sh: 3: example.sh: Syntax error: "(" unexpected. And this is the script #!/bin/bash array=( one two three ) If I run the script with ./example.sh it works and no...

Unable to connect to mysql after automating mysql-server installation in bash script

mysql,linux,bash,unix
Generates a random string: passdb="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-2};)" Feeds passdb to debconf i.e to set random passwords for mysql users: debconf-set-selections <<< 'mysql-server mysql-server/root_password password $passdb' debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password $passdb' apt-get -y install mysql-server It get's installed successfully but I'm getting an error after...

The range of virtual memory address in userspace

c,linux,memory
In linux, the range of virtual memory address in userspace, in other words, the range of value returned by malloc, is same as entire 64bits virtual memory space? Or, is there any sub-range of 64bits virtual memory space which is guaranteed not to be seen in userspace? Answers for UNIX...

How does the kernel separate threads from processes

linux,multithreading,linux-kernel
Suppose I have a browser process like Firefox, that has pid = 123. Firefox has 5 opened tabs each running in a separate thread, so in total it has 5 threads. So I want to know in depth, how the kernel will separate the process into the thread to execute...

error using already compiled version of openCV

c++,c,linux,opencv
I've used the already compiled version of openCV for Raspberry Pi. link for anyone who is interested After trying to compile using this command line g++ test3.cpp -o test3 -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lopencv_core -lopencv_highgui -lopencv_imgproc -lwiringPi -lpthread I get the following error lines. //usr/local/lib/libopencv_stitching.so.2.4: undefined...

make error during building webkitgtk

linux,makefile,cmake,make
I use UBuntu 14.04 LTS. I need to build webkitgtk 2.8.3 Here is an example instruction which I have used: linuxfromscratch When I run sudo make -j8 I get following log: Scanning dependencies of target JavaScriptCore-4-gir Scanning dependencies of target fake-generated-webkitdom-headers [ 0%] Scanning dependencies of target WebKit2-fake-api-headers Scanning dependencies...

count the values based on condition in log

linux,shell
I have a log like below 11 13/06/2015:00:02:37 10 13/06/2015:00:02:38 7 13/06/2015:00:02:39 10 13/06/2015:00:02:40 1 13/06/2015:00:02:42 1 13/06/2015:00:02:50 1 13/06/2015:00:02:54 2 13/06/2015:23:41:46 1 13/06/2015:23:41:47 2 13/06/2015:23:41:48 1 13/06/2015:23:41:49 2 13/06/2015:23:41:50 1 13/06/2015:23:41:51 2 13/06/2015:23:41:52 1 13/06/2015:23:41:53 2 13/06/2015:23:41:54 1 13/06/2015:23:41:55 1 13/06/2015:23:59:50 2 13/06/2015:23:59:51 2 13/06/2015:23:59:52 2 13/06/2015:23:59:53 2 13/06/2015:23:59:54...

Linux : pthread_cond_signal() is not working inside a Signal Handler()

c++,c,linux,signals,posix
Summary ----------- 1. In main() am going for pthread_cond_wait(). 2. In signal handler() am waking main() using pthread_cond_signal(). 3. But main() is not coming out from pthread_cond_wait(). What is wrong here? help me out. #include <stdio.h> myclass *myObj = NULL; In main I am trying to wait for a signal:...

how to spy on linux binaries for testing of shell scripts

linux,bash,shell,testing,spy
sorry if this is a duplicate, i had no idea what to search for... my use case is more complex, but can be narrowed down to the following problem: i want to run a bash script, which invokes all sorts of binaries, for example: grep. i want to assert that...

Reading from linux command line with Python

python,linux,shell,command-line
Is there a way to read data that is coming into the command-line, straight into another Python script for execution?

why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

c,linux,kernel,linux-device-driver
I see u8 u16 u32 u64 data types being used in kernel code. And I am wondering why is there need to use u8 or u16 or u32 or u64 and not unsigned int?

Piping echo into sendmail in rc.local fails

linux,shell,email,sendmail,boot
I'm trying to get my system to send me an email when the system boots. Using the following command works as intended: echo -e "TO:[email protected] \nSUBJECT:System Booted \n\nBeware I live! \n"$1 | sendmail -t -vs But if I add it to rc.local like so: #!/bin/sh -e # # rc.local #...

Nginx block access to referring url

linux,nginx,dns
I've discovered a domain is pointing to my servers IP address as an A-record. I've tried to implement various measures to have have it blocked. I can block it accessing assets on the server i.e loading JS/CSS files and I can block it when a link is accessed from within...

What are valid input DATE formats for the (Linux) date command?

linux,bash,date,scripting
The following command generates the date for the next day: date -d "20150615 12:00 +1 day" +%Y%m%d 20150616 I would like to specify my own INPUT date format, such as: 2015_06_15 But the date command does not like this format and complains about invalid date: date: invalid date '2015_06_15 12:00...

sed and PHP tags

regex,linux,sed
I have a problem using SED. I have a php file whit this structure in the very first line: <?php echo 'first' ?><?php echo 'second' ?><?php echo 'third';?> I'm trying to remove the first two statements and have as a result: <?php echo 'third';?> I've tried this code: sed -i...

How to copy matches from an extremely large file if it contains no newlines?

python,linux,bash,perl,grep
The problem is I cannot avoid working with extremely big files which contain no newlines in them: <a>text1</a>...gigabytes of data here, all in one single line...[a text to extract b> What should I do if I want to copy matches from this file (putting every match in a separate line,...

Using linux sort on multiple files

linux,sorting
Is there a way I can run the following command with Linux for many files at once? $ sort -nr -k 2 file1 > file2 ...

How to make new line when using echo to write a file in C

c,linux,file,echo,system
hi ı am triying to take the data of files in a folder with system function this is the code char path[100],command[120]; scanf("%s",&path); sprintf(command,"echo $(ls %s) > something.txt",path); system(command); but when I look to the something.txt there is no new line. This is the output, all on one line with...

how to compare only date from a model's datetimefield with current date?

python,linux,django,web,frameworks
I want to use Model.objects.filter(datetime_lte=datetime.datetime.now.date()) How exactly can I achieve this? I am using django 1.6.5. I want only records of current date. This will give all previous day's records also

Force linux to use php as php55

php,linux,fedora
Helllo, I have a little problem here. I have PHP 5.3 installed and it's accessible via php command, I also have php 5.5 accessible as php55 command. Now I need to force linux to use php55 when I write php command. Simple way: How I switch the versions of php?...

ret_from_syscall source code and when it is called

linux,linux-kernel,kernel,linux-device-driver,system-calls
In the below call trace we see function called ret_from_syscall. Which function is this ? When it will called during system call ? Where is the corresponding code for this ? May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddc0] [00009751] 0x9751 (unreliable) May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddd0] [c00469ac] do_syslog+0x198/0x424...

How to extract first letters of dashed separated words in a bash variable?

linux,string,bash,shell,variables
I would like to extract the first letter of dashed separated words value of my bash variable, like this: MY_TEXT=this-is-my-custom-text I would like to create a second variable like this: MY_INITIALS=timct...

Group of data in shell language

linux,bash,shell
I wonder if the data in the group aren’t numbers ; the script works? When x="1 2 3" I can do a for loop: for i in $x I wonder if this is correct : read x read y xm=`cat $x` ym=`cat $y` zm="$xm $ym" for i in $zm do...

Extract minor version from kernel to bash variable

linux,bash,sed,cut
I am new to bash and writing a script that needs to compare the minor version of the kernel to see if it is greater than or equal to 10, and exit if it is not. Currently I have something like: KERNEL = $(uname -r) declare -i MINOR_VERSION=$(echo $KERNEL |...

debian 8: deb command not found. How can i fix it? [closed]

linux,debian,deb
I am trying to install graphics card Nvidia Geforce 660 on my desktop. Os: debian 8. Here is the wiki which gives guidelines : https://wiki.debian.org/NvidiaGraphicsDrivers#jessie-304xx But as soon as I am on the first step: deb http://http.debian.net/debian/ jessie main contrib non-free bash: deb: command not found How can I install...

How to find average and maximum in an interval using Shell [closed]

linux,bash,shell,unix,awk
I would like to extract sum, mean and average in each 6 numbers interval from a column. I found many discussions related to this problem, but all those are for whole column. e.g. To compute sum of a column: awk '{sum+=$1} END { print sum}' To calculate Average: awk '{sum+=$1}...

awk error: each rule must have a pattern or an action part

linux,gawk
From here I got the following command: awk '/em1/ {i++; rx[i]=$2; tx[i]=$10}; END{print rx[2]-rx[1] " " tx[2]-tx[1]}' \ <(cat /proc/net/dev; sleep 1; cat /proc/net/dev) which is fully working as intended. However, I would the output in Mbps, so I created 2 commands, one for upload, one for download (both working):...

Use Xargs to wait for enter key

linux,bash,shell,xargs
So, I have a list of files that I want to use to generate a new set of groups of files. I want to open up these groups (multiple files) together at once. Edit them. Then go back to the terminal, hit enter, and open up the next group of...

AWK write to new column base on if else of other column

linux,bash,shell,awk,sed
I have a CSV file with columns A,B,C,D. Column D contains values on a scale of 0 to 1. I want to use AWK to write to a new column E base in values in column D. For example: if value in column D <0.7, value in column E =...

Git post-receive hook is not executed

linux,git,githooks,git-post-receive
The following post-receive hook: #!/bin/bash echo "-> Post-receive test" is not executed when pushing to my remote repository. The remote is ssh:[email protected]:2222/home/git/repo.git (it's a VM) and works, as when I manually checkout it I see the modifications I've made. Some additional informations ... $ ls -al /home/git drwxr-xr-x 7 git...

Spring batch FileItemWriter not creating file at correct path

java,linux,spring,websphere,spring-batch
I have a spring batch service containing a FileItemReader,FileItemProcessor and FileItemWriter.When creating the FileItemWriter I have to set the Resource that will be my output file. I am running the batch service on websphere on a Linux machine.The problem is if I set the resource as new FileSystemResource(new File("opt\temp1\myFile.txt")), the...

How to remove characters before and including an underscore?

linux,string,bash,unix,awk
In bash scripting what's an efficient way to do the following please? var="fooo_barrrr" What is the best way to remove all characters before and including the '_' so that var becomes "barrrr" please?...

linux running command as root from c code that run as normal user

c++,linux
I have a c++ code and I need to running from it a command to adjust the system time. so I thought using system("su root -c date hh:mm") command from my c++ code. The problem is that when I write 'su root -c date hh:mm' in the terminal its requires...

How to check which symbols on my shared library have non-position independent code (PIC)?

linux,gcc,debian,powerpc
I'm trying to build a .deb package with debuild -i -us -uc -b and in the end I see: Now running lintian... warning: the authors of lintian do not recommend running it with root privileges! W: libluajit-5.1-2: hardening-no-relro usr/lib/powerpc64le-linux-gnu/libluajit-5.1.so.2.1.0 E: libluajit-5.1-2: shlib-with-non-pic-code usr/lib/powerpc64le-linux-gnu/libluajit-5.1.so.2.1.0 W: luajit: hardening-no-relro usr/bin/luajit-2.1.0-alpha W: luajit: binary-without-manpage...

Two part: How to run 'ls' from a java program and how to tell computers on a storm cluster to execute specific commands

java,linux,storm,topology
So writing a test storm topology with minimal java experience, so i'm figuring things out in a brute force way. My experience writing storm topologies is also minimal. I have three supervisor nodes on my cluster and want each of them to run ls in the terminal, funnel the output...

Error while executing lsof from bash script

linux,bash,shell,scripting
I am trying to check for the process which are running on a particular port and if present kill them, as i have to start another process on that port. Below is my code snippet. #!/usr/bin/env bash TEST_CASE_PATH="$HOME/Projects"; #kill Previous Process Running on port 9130 OUTPUT="$(ls -1)" echo "${OUTPUT}" #...

Continuous data stream from linux command line into python script

python,linux,command-line,tcp,pipe
I need to get a continuous stream of data flowing from a peripheral device, to a raspberry pi, and lastly to my computer (mac). So far, the data is can make its way continuously (in real time) from the peripheral, to the command line of my raspberry pi. Note that...

sed string with special character New

linux,sed,special-characters
when i use this script to replace : mrm.fr.mycompany.com by 10.70.89.40:8081/artifactory sed -i -e "s/mrm.fr.mycompany.com/10.70.89.40:8081/artifactory/g" config.xml i have the error : sed: -e expression n°1, caractère 41: option inconnue pour `s' can anyone help me thanks in advance regard, Youssef...

How to open a new terminal from my working terminal with same directory in Linux?

linux,unix,ssh
Is there any command to open a new terminal from my working terminal with same directory while working with ssh in Linux? e.g., I am working in the following terminal. My pwd is /home/work/Kayan01/test_run I want to open a new terminal directly from my working terminal, so that the pwd...

Calling find more than once on the same folder tree

linux,bash,shell,unix,find
I'm running a find command multiple times on the same group of files. The results of my find commands are usually disjoint sets, AKA I'm running find -mmin +35; find -mmin -25, and doing different things to the results. It seems sort of silly to search through the entire file...

Recursively copy /dev/null to file pattern

linux,command-line,zfs
I am using a ZFS system that has reached its disk quota. As a result, the rm command no longer is available to me. However, I am able to copy /dev/null to particular files to effectively remove them. The issue is that the directory I am trying to clear out...

How to append entry the end of a multi-line entry using any of stream editors like sed or awk

linux,bash,awk,sed,sh
I am trying to use a script to append the host name at the end of a multi-line entry of a specific Host_Alias field in sudoers file. The current sudoers file has an entry similar to : Host_Alias srv_linuxestate= \ host10,host12,host13,host1,host50,\ host16,host1,host2,host11,host15,host21,\ host3,host14 My required output would be something like...

Check string index exist

linux,bash
how to we check if string index is exist in array for example declare -A SArray SArray[a]="a" SArray[b]="b" read index now on index i want to check if index is exist in SArray ...

How to look at the top 30 lines (or head) of all files inside a directory?

linux
If I have 30+ files in a directory /a.cpp /b.cpp /c.cpp ... What's the fastest way to export the head (top n lines) of all files into one single document? Thanks....

What does it indicate if /proc/PID/maps shows zero for all addresses?

linux,linux-kernel
I'm debugging a problem with a Linux DNS server. Curiously, when I look at /proc/PID/maps for the DNS server process, this is what I get: 00000000-00000000 r-xp 00000000 00:0e 2344 /usr/sbin/unbound 00000000-00000000 rw-p 00000000 00:0e 2344 /usr/sbin/unbound 00000000-00000000 ---p 00000000 00:00 0 00000000-00000000 rw-p 00000000 00:00 0 [heap] 00000000-00000000 rw-p...

BASH - conditional sum of columns and rows in csv file

linux,bash,csv,awk
i have CSV file with some database benchmark results here is the example: Date;dbms;type;description;W;D;S;results;time;id Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;570;265;50 Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;420;215;50 Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;500;365;50 Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;530;255;50 Mon Jun 15 14:22:20 CEST 2015;hsql;on-disk;text;2;1;1;870;265;99 Mon Jun 15 14:22:20 CEST 2015;hsql;on-disk;text;2;1;1;620;215;99...

How To Restore a Missing Redis Service

linux,redis,centos
I installed an older version of Redis on a CentOS server. I tried to remove that old version and update it to latest version, but it seems that the redis service is gone and the new version installation doesn't reproduce it. Is there any way I can uninstall the Redis...

Using indirect variable references in a Bash script

linux,bash
I have lots of old log files in a directory, with apps logs generated every month to this directory. I want to use a script to remove only the last month old logs. This is my file logsDir , these files are 0kb, i have created for question understanding [[email protected]..

Finding the average of a column excluding certain rows using AWK

linux,bash,awk,scripting
I want to calculate the average of the 5th column (last column) excluding the rows with the value "9999". Would appreciate your feedback. 77.300 16 1 3.6112914285714268 9.4 77.300 16 2 -0.001737142857145102 20.0 77.300 16 3 5.1570742857142857 8.9 77.300 17 0 3.6112914285714268 8.9 77.300 17 1 2.9484342857142849 11.7 77.300 17...