You need to properly quote anything with spaces or other shell specials in it. As a matter of fact, unless you really know what you are doing, get into the habit of double-quoting all variables.
Probably the shell fails to expand your variables the way you want them to be expanded. If you have variables containing spaces use double quotes to make sure they get expanded into one argument and not several.
To understand try the following: save the following to a file countargs.sh and make it executable:
Now lets experiment: what do you think is the result if you substitute the "sed" in your command with the "countargs.sh" script? What is it really?
sed has a command syntax of "sed COMMAND FILE" if you present it something like "sed s/x /y /g some_file" it will think "s/x" is the command (which leads to a syntactical error of course) "/y" is the file and the rest is ignored. Only if you write sed "s/x /y /g" "some_file" it will treat "s/x /y /g" as the command argument and "some_file" as the file argument.
Solution for your problem: write
to be on the save side. Generally: quote enthusiastically - always! ;-)) In programming it never hurts to be overly pedantic.
In my further exploration of Arduino, today I decided to install the arduino-cli on my mac today.
https://github.com/arduino/arduino-cli
I followed the instructions for macOS but when I got to this part:
arduino-cli board list
I got the dreaded "Unknown" Fully Qualified Board Name... (1 Reply)
Hello,
I am running ubuntu 16.04 .
Below script gives: "unknown command '\;'
counter=105
while read COL1 COL2 COL3
do
let counter++
url="http://localhost/test/$COL1.$COL2.$COL3";
mysql -uroot -D mydatabase -pmypasswd -e "SELECT video_id FROM video_series_files WHERE id IN \
(SELECT... (12 Replies)
Hi All,
I'm relatively new to Unix scripting and am trying to get my head around piping.
I'm trying to take a header record from one file and prepend it to another file. I've done this by creating several temp files but i'm wondering if there is a cleaner way to do this.
I'm thinking... (10 Replies)
Hi,
I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :-
./sample.sh: line... (12 Replies)
My OS is Linux GL version 2.4.26. I am trying to make a shell script that outputs a chart displaying info of who is online, boot time, and the real time, I have manage to get it to work, but I still get the error "./user/script: line 1: : command not found." I do in fact have access to root, if... (2 Replies)
My environment is HP-UX...
NIS CEL | uname -a
HP-UX s53kj113 B.11.11 U 9000/800 1510201964 unlimited-user license
I ran this command directly from the server's sqllplus. Logically, it should have work.
But in my case, it always escaped the 1st character of the next command after the... (3 Replies)
Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line.
... (1 Reply)
Sorry for the duplicate thread this one is similar to the one in
https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121
Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Hello,
I have a problem - I created a chrooted jail for one user. When I'm logged in as root, everything work fine, but when I'm logged in as a chrooted user - I have many problems:
1. When I execute the command ping, I get weird results:
bash-3.00$ usr/sbin/ping localhost ... (4 Replies)
Hi,
we are running solaris 9 on V280R. Due to power failure, one disk's label and lost its details like drive type etc.
Disk details:
<SUN72G cyl 14087 alt 2 hd 24 sec 424>
single partition on slice 6 with UFS.
The below i see when i run "format" command
.....
.....
4.... (1 Reply)