Strings are typically delimited by quotes, which raises the problem of dealing with strings that include quotes.

learn more… | top users | synonyms

1
vote
4answers
55 views

execute command over ssh connection [duplicate]

I want to excecute the following command over a ssh connection: tmpValue=$(cat /var/run/jboss-as/jboss-as-standalone8.pid) && top -b -U jboss -n 1 |grep $tmpValue |awk '{print $9}' This ...
2
votes
1answer
28 views

How to get a list to be entered in quotes

firstly I am a total n00b with scripting, so please forgive any incorrect terminology. I have a simple script that runs a python script (used to deduplicate emails via IMAP) after a user has entered ...
1
vote
3answers
38 views

Unable to use a escape sequences in a variable in a sed command

I'm using sed to highlight a column in the output of a ps command, and it works fine if I hard code the color code. However, the color needs to be dynamic, so I tried moving it to a variable, and ...
2
votes
2answers
64 views

Why won't this bash command run when called by python?

The command $ find ~/foo/ -type f -iname "*.txt" -print0 | parallel -0 cat uses GNU Parallel to print all the .txt files under ~/foo/. I have a python script where I want to call this bash ...
0
votes
3answers
50 views

How do I remove a dot dollar no name directory

I have this weird directory in Oracle Linux that I cannot remove, cannot change owner, cannot change group, etc. It seems to be an environment variable that is empty and is named: .$EXTEND Here's ...
0
votes
1answer
35 views

globbing and wildcards

Are wildcards ever supposed to be expanded for a program that is not the first in the pipeline? Every example uses wildcard for the first program in the pipelilne. For example, the following does ...
0
votes
3answers
64 views

Right syntax for awk usage in combination with other command inside xargs sh –c

How to make this command work: ls * | xargs -I {} sh -c 'echo {}; awk '{print $1}' {} | uniq' It should do the simple thing: print for each file in the folder its name and uniq values in the first ...
2
votes
1answer
24 views

Why is a daily .zshrc reload required using an alias containing $(date -u +%Y%m%d)? [closed]

Each morning I run the following command that tails a log file created daily: ssh -t server@55.555.55.55 tail -f development/abc/$(date -u +%Y%m%d).log This works just fine and each morning the log ...
3
votes
1answer
97 views

Syntax error with variable containing quotes

I have a bunch of Linux machines behind 2 gateways. To connect to set one I do ssh -o ProxyCommand="ssh gateway1 nc %h %p" machines_behind_1 ssh -o ProxyCommand="ssh gateway2 nc --proxy %h %p ...
0
votes
1answer
28 views

syntax error: unterminated quoted string when using regexp_replace in bash script

I've added some code to the end of a bash script I am using. The code shown here is intended to copy a csv into my postgres table, and then remove brackets, quotes and double quotes from the title ...
2
votes
1answer
35 views

Passing a git command as an argument

I'm trying to automate some tedious parts of a student job I'm working on. Basically, the goal is to clone a bunch of git repositories (which I already have working), then run the same git checkout ...
0
votes
1answer
47 views

command substitution - cat file inserts quotes

In bash, given these files: $ cat noquotes.txt s/a/b/g $ cat quotes.txt "s/a/b/g" Why does $ echo "aaa" | sed -e $(cat noquotes.txt) bbb succeed, but $ echo "aaa" | sed -e $(cat quotes.txt) ...
7
votes
1answer
1k views

Why does `grep fil*` fail?

I found echo file|grep fil* fails, but echo abcd|grep abc* succeeds. I don't understand it, can someone explain? Thanks
4
votes
2answers
45 views

Store quotes in variable to use as command line parameter Bash

I am writing a script to call a command (weka, if you are curious) a couple of times with some different parameters. One of the parameters, '-search "< stuff >" ' needs to be quoted. In some ...
0
votes
1answer
63 views

grep with variable in a variable

I want to filter the svlog file by date and split the result by the space, so when i enter the date, it didn't work for me, please refer to the script that I wrote below, the problem was in this ...
1
vote
1answer
38 views

Rewrite a find command that uses sed -i for AIX

I have a script that searches for a string and replaces it via the sed command. If that string contains special characters, the script will escape them (except for the slash because it's my current ...
1
vote
2answers
52 views

Shell eating `?` characters

This is such a simple question that I'm sure it's been asked somewhere, but I can't find it. My shell, which I have not intentionally set up to do so, seems to eat any words involving question marks: ...
0
votes
0answers
31 views

Why do konsole expand $VAR inside single quotes in <-e> command line option?

I want to print a string and be sure all $VARs inside it are not expanded to their values. That's why I enclose my text in single quotes. Example: echo '$SHELL';read -sn 1 This command displays ...
0
votes
0answers
13 views

Bash script not passing variable through ssh [duplicate]

I'm trying to write a script that will ssh into multiple servers and echo the line user_pref("plugin.state.java",2) into every user's firefox pref.js file. I keep getting the error bash: ...
1
vote
2answers
50 views

Define a variable to awk pattern matching from bash

I am trying to grab 100 lines after the text "time: X" with X in {0,40,80,...,200}. Here is what I have so far: #!/bin/bash start=1 end=5 for i in $(seq $start $end);do j=$(($i*40)) awk '/time: ...
1
vote
0answers
28 views

Passing external parameter to .exe on Windows using winexe from Linux

I am trying to execute a .exe on Windows from Linux using winexe. This exe requires an external parameter (string) to be fed alongwith. With the following command I have succeeded in initialising the ...
2
votes
4answers
646 views

Why does the grep command ignore the period in the search string?

The command that I am using: find . -type f -name "*.sql" -exec grep -i -l 'schema_name.' {} + What I want to search is all the files which contain schema_name.. But the find command is ignoring ...
1
vote
2answers
90 views

Escaping in bash

Given a text message, I need to programmatically generate a bash command to open terminal emulator and show this text in it. For example, for HelloWorld input string I need to return the following ...
1
vote
1answer
72 views

regular expression : with a variable

arrFormat=( jpg jpeg bmp tiff png ) varExtension="jpg" for elem in "${arrFormat[@]}" do   echo "${elem}"   # do something on $elem # done #for i in $( find -E . -iregex '.*\.($arrFormat)' ) ; do ...
0
votes
1answer
69 views

How do I accept input string in bash without losing the quotes?

Example, I have this function in my .profile: alias () { command alias "$@" } However, this executes: $ alias test=ls if I run $ alias test="ls" How can I make it accept the string with ...
16
votes
1answer
1k views

Why does this ffmpeg command work in bash and not zsh?

Today I got home from work (run bash on an Ubuntu box) and tried to run some code on my local arch box with my beloved zsh and the commands were failing? The command is below with the personal info ...
1
vote
2answers
67 views

Why some commands don't load user environment when executed with ssh? (while other do)

On a target machine (OS X El Capitan) I have brew in /usr/local/bin. When I try to get brew's path I get no result: # ssh vagrant@127.0.0.1 -p 2222 which brew # Troubleshooting: brew is in ...
3
votes
1answer
249 views

What characters are required to be escaped in command line arguments?

In Bash, when specifying command line arguments to a command, what characters are required to be escaped? Are they limited to the metacharacters of Bash: space, tab, ‘|’, ‘&’, ‘;’, ‘(’, ‘)’, ...
1
vote
4answers
56 views

Why does read with pipeline fail in an ssh session?

Why does this show blank lines instead of folders found by find? ssh -o stricthostkeychecking=no -o userknownhostsfile=/dev/null \ -o batchmode=yes -o passwordauthentication=no user@myserver.xx \ ...
0
votes
2answers
36 views

bash script function argument problem [duplicate]

Not sure why this is producing error. This is a test code emulating my real code. I want to write a wrapper for find and want to allow for any argument, so I'm wrapping each arg in single quotes. ...
7
votes
1answer
580 views

What does `\time`, `t\ime` and `\cd` actually do? (fun with backslashes in shells)

While discussing over the differences between /usr/bin/time and the shell (bash and zsh) built-in time, someone mentioned that one can use \time as a shorthand to get /usr/bin/time. First it seemed ...
3
votes
2answers
393 views

Printf printing only a single line

I'm trying to get the output of env in a shell variable and print it. #!/bin/sh ENV_BEFORE=$(env) printf $ENV_BEFORE As a result a single variable from the env output gets printed. When using echo ...
1
vote
0answers
37 views

Copy file into all subdirectories that contains a file with certain name

I am trying to copy a features[30,55].R script from my desktop into all the subdirectories that contain a file whose name is DONE. I tried the following command: find . -name "DONE" -exec sh 'cp ...
1
vote
1answer
26 views

Manual pages uses the quotation : `<character/string>' (quoting string inside grave accent and apostrophe) [duplicate]

I've found that many manpages uses the quotation :  `c/s' i.e quoting character or sting inside grave accent(`) & apostophe('). Example visit manpage of bash, find etc. and you'll find the ...
1
vote
2answers
104 views

Using special character " and ` in send command in expect script

I am trying to execute a command in Linux servers to fetch which all servers requires root password reset as there are multiple servers I am using an expect script to automate it , my command contains ...
3
votes
2answers
161 views

Why the defined path is used as file name when I transfer files through scp to a Windows host?

When trying to copy a file from Linux (Raspbian to be precise, though I don't think it matters) to Windows using SCP: scp a.txt {user}@{ip}:\C\Users\{user}\a.txt The file is copied, but to ...
3
votes
2answers
75 views

Passing a list of two PIDs to xargs only kills the first using ssh

I'm retrieving a list of two PIDs that I want to kill. My pipeline looks something like ps -ef | grep foo | grep -v grep | awk {'print $2'} | xargs kill -9 Both processes are killed when executing ...
3
votes
1answer
56 views

On passing arguments to programs through array variables

NB: though the question below features rsync, it is not a question about rsync; it is a question about zsh arrays. If I initialize the variable EXCLUDES like this EXCLUDES=( --exclude=/foo ...
1
vote
2answers
79 views

find “corrupt” file, nesting an if inside a find command

I'm trying to find "corrupt" files inside a directory structure, namely files which the file command would interpret as "data". Here is the command I've been trying to run, but fails: $ find . -type ...
3
votes
3answers
159 views

cannot move file because of & in name

Trying to command mv foo&foo.jpg images/ but get command not found, then if try and rename the file it won't let me.
1
vote
1answer
73 views

bash adds apostrophes to expanded variable

I am reading in a file inside my bash script where each line consists of multiple columns like this: ANSIBLE 'first run' '--diff --extra-vars "client=yes fast=no"' As you can see, the line consists ...
0
votes
2answers
48 views

Define string with the characters *, single quote and $

I create bash scripts which get sourced from another "main" script to set up variables needed by the main script. These variables need to be able to contain any character and not have them interpreted ...
3
votes
4answers
69 views

Bash converting path names for sed so they escape

I'm having a problem with a script. It is meant to change a value in a file called %DIR% so that it becomes a path name. The problem is the slashes in the directory name upset sed, so I get weird ...
1
vote
1answer
67 views

How to escape a range of wildcards in unix shell script?

I need to execute the following Oracle SQL in unix crontab. The query is as follows: select count(*) from tbaadm.htd where cust_id is not null and pstd_flg = 'Y' and del_flg = 'N' and tran_date = ...
0
votes
2answers
94 views

Bash syntax error when `cd`ing into directory

**So, after doing a little digging, I got it to work. You do get far enough in the install using WINE for this to work properly. Here are the steps: Open the shell, and type in cd .wine ...
1
vote
1answer
45 views

Nested strings in bash command [duplicate]

I am attempting to write a script to list all the shebang lines in python files. What I would like to do is sudo bash -c 'for logf in $(find / -name "*.py"); do fgrep '#!/usr/bin' "$logf"; done' ...
4
votes
2answers
88 views

confusing about double quoting

I learned when I use command, double quoting treat all things as character except $, `, \ . But, when use command like find -type f -name "*.jpg" *.jpg is inside double quotes. Then, it means we want ...
1
vote
1answer
48 views

Globbing error due to whitespace

My directory variable POSTMAP="/work/Documents/Projects/untitled\ folder/untitled\ folder/*/*_tsta.bam" My for statement: for file0 in ${POSTMAP}; do ... It seems that the whitespace in ...
0
votes
1answer
45 views

Unable to move files having spaces in their name [duplicate]

I want to move files from one folder to another folder, my code is working fine when file name doesn't contain spaces but if there is a space in a file name then I am getting an error My Code is as ...
2
votes
1answer
54 views

Why are these nested options in a POSIX shell script being word-split?

I have a script count_args that counts arguments: #!/bin/sh echo $# If I call it with these options, it tells me it gets two arguments: $ ./count_args --options '1 2' 2 But if I construct the ...