The left part data (in variable) like : echo "$lpart" "2017-07-03 13:39:5", "-39dB", "7c:e9:d3:f1:61:55" "2017-07-03 13:39:5", "-39dB", "7c:e9:d3:f1:61:55" "2017-07-03 13:39:5"
How do I read a row of data and assign them to variables while also giving them default values? I wanted to achieve something like this, but can't get the syntax right. { read variable1=${variable1:=default1} variable2=${variable2:=default2} read var
I want to run a set of commands out of which some I want to run simultaneously in another terminal using shelll script. Let's say I have the below four commands command1 command2 command3 command4 First I want to start command1 in terminal 1 & while
#!/usr/bin/env bash function foo(){ param=$1 echo "$param" } content="calling this one with param: $(foo 'this is test param1')" echo "$content" result: calling this one with param: this is test param1 Notice that foo is call
This was what I have tried grep -n 'qtrain' *.m But I got also SKSC.m:195:model.qtrain = model.qtrainExtra(:,k-1); SKSC.m:196:model.mqtrain = model.mqtrainExtra{k-1}; SKSC.m:197:model.sqtrain = model.sqtrainExtra{k-1}; How to get rid of the others? I
I have to write a bash script that launches a process in background in accordance to command line argument passed and returns if it were successfully able to run launch the program. Here is a pseudo code of what I am trying to achieve if [ "$1"
i made a web server to show my page locally, because is located in a place with a poor connection so what i want to do is download the page content and replace the old one, so i made this script running in background but i am not very sure if this wi
This question already has an answer here: How to exclude a directory in find . command 29 answers I'm using the find command to get a list of folders where certain files are located. But because of a permission denied error for certain subdirectories
Good day. I was reading another post regarding resolving hostnames to IPs and only using the first IP in the list. I want to do the opposite and used the following script: #!/bin/bash IPLIST="/Users/mymac/Desktop/list2.txt" for IP in 'cat $IPLIS
I'm not completely clear on the how/why bash's exit keyword is inconsistant when calling a function that expects a return vs. not expecting a return. For instance, in the following repro: #!/bin/bash exitfunc() { echo "Flag 1" exit } exitfunc ec
Using $@ inside a bash test expression gives odd results. Here's a minimal test script to reproduce the issue (among the alternative formulations for the same test which do pass without error): #! /bin/bash # file path: ./bash_weirdness.sh echo "args
I want to write a script in bash that handles a file with lines that has 5 columns and i expect the delimiters to be one single space (" "). everything other than that should lead to an error, even more than 1 space. for instance, that line is l
At first, I parsed an array JSON file with a loop using jshon, but it takes too long. To speed things up, I thought I could return every value of id from every index, repeat with word another type, put these into variables, and finally join them toge
Trying to figure out the best way to automate running a command that takes a lot of parameters and changing some of them. Current approach is this: #!/bin/bash # 5 more of these VALUE=42 STUFF=12 CHARLIE=96 # Note that these are not sequential, just
I have a file with very, very long lines. A single line will not fit in memory. I need to process each line separately, so I'd like to write each line to a FIFO node, sending EOF between lines. This model works well for what I'm doing, and would be i
I am learning Linux commands and I learnt that you can write a shell script and put in a customized directory (e.g. ~/bin/ ) and export to $PATH or you can write it as a shell function and put in .bashrc file. If I may ask, what is the right situatio
Would like to reference the full path to the which command as an improvement to some shell scripts. Is anyone aware of a standard location for some unix gnu/linux distribution BESIDES /usr/bin/which?which is not a standard part of linux systems. It's
I have a text file, it contains a single word on each line. I need a loop in bash to read each line, then perform a command each time it reads a line, using the input from that line as part of the command. I am just not sure of the proper syntax to d
I'm making an ajax request which is making bash treatment. Another action in my page uses an ajax request but this one is waiting the end of my first request for making what I'm asking. Do you have any idea for doesn't waiting the end of the first aj
This question already has an answer here: Creating an array from a text file in Bash 6 answers I am trying to read a file containing lines into a Bash array. I have tried the following so far: Attempt1 a=( $( cat /path/to/filename ) ) Attempt2 index=
I have a file which contains lines of data in the following format: a11 a12 a13 a14 a15 a21 a22 a23 a24 a25 a31 a32 a33 a34 a35 a41 a42 a43 a44 a45 . . . what I need is to save this data in a new file with the following format after performing some a
The last 3 lines of wget -i urls.txt: FINISHED --2012-05-16 12:58:08-- Total wall clock time: 1h 56m 52s Downloaded: 1069 files, 746M in 1h 52m 49s (113 KB/s) There are two different times: 1h 56m 52s 1h 52m 49s Why are they different? What do they s
You can use \d in the your PS1 confuration to display a long date ie. Tues 18 May, but how can I get it to display it in a format like 18.05.2012 for example?Try this: PS1="\$(date +%d.%m.%Y) > " export PS1
I want to return an exit status of 0 if the output is empty and 1 otherwise: find /this/is/a/path/ -name core.* When you say you want it to return a particular number, are you referring to the exit status? If so: [[ -z `find /this/is/a/path/ -name co
I'm trying to run a script which uses my $HOME variable to set things up (it's gitolite, by the way). However, it's failing because I'm on a system where the home directory path has spaces in it. I want to hack the gitolite bash script at a single po
I just want a bash script to run 5 minutes after it's called. What am I doing wrong? I have the command: /path/to/my/script | at now + 5 min And yet the script runs right away every time.You are executing the script immediately and sending its output
I got in every php project (around 25!), some sh scripts that help me with routine tasks such as deployment, repo syncronizing, databases exporting/export, etc. The sh scripts are the same for all the projects I manage, so there must be a configurati
I am in the process of creating a bash script that would log into the remote machines and create private and public keys. My problem is that the remote machines are not very reliable, and they are not always up. I need a bash script that would check
I have a C++ program that will run on several machines that use a Network File System. For each of the C++ libraries that my program uses, I installed a version for each machine, under ~/program_files/machinename/libraryname. "machinename" is ob
Every time I use the "at" command, I get this message: warning: commands will be executed using /bin/sh What is it trying to warn me about? More importantly, how do I turn the warning off?It serves as a good warning to those of us that don't use