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

learn more… | top users | synonyms

19
votes
1answer
718 views

Why doesn't 'find' show this file?

Using find with grep, one can locate files that match a pattern: # find | grep error ./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html ./error_log ./includes/classes/error_log However, using ...
0
votes
1answer
293 views

Quotes exercise - how to do ssh inside ssh whilst running sql inside second ssh? [duplicate]

Possible Duplicate: Quoting in ssh $host $FOO and ssh $host “sudo su user -c $FOO” type constructs Wrapping a command that includes single and double quotes for another command I want to ...
4
votes
2answers
169 views

Is there any reason to escape a dot in a bash filename expansion?

I am working with a bash script that someone else wrote and I see the following line: cp -v ${LOG_DIR}/${APPLICATION}\.*.log ${ARCHIVED_LOG_DIR} The files with which it's working are all named ...
1
vote
0answers
84 views

How to make tcsh not insert whitespace in a command that spans multiple lines

Bash does not seem to insert whitespace but tcsh does. Tcsh bash-3.2.25$ tcsh -c 'echo $tcsh; echo A\ > B' 6.14.00 A B Bash bash-3.2.25$ bash -c 'echo A\ > B' AB How can I ask tcsh to not insert ...
0
votes
1answer
76 views

Find and use the path of a file?

I'm trying to find the path of a file and move it. When I try realpath, it is not useful. For example : I want to move the file All Hail the Generalist - Vikram Mansharamani - Harvard Business ...
6
votes
2answers
384 views

Why does --text=“$@” only pass the first word?

When I run the following script with some arguments like arg1 arg2 arg3: #!/bin/bash zenity --entry --text="$@" zenity creates an entry dialog with this text: "arg1" whereas I expect "arg1 arg2 ...
3
votes
1answer
520 views

Printing colored text using script

When I type below command in the shell I get the OUTPUT in green color. Command echo "\033[32mCONNECTING TO abpwrk\033[m"; Output(in green color) CONNECTING TO abpwrk But if I use the same ...
4
votes
5answers
3k views

How to enclose in quotes if both single and double quotes are already used?

I don't remember the exact commands and tricks that I use sometimes which solves much of the work, so I try to log them into a file for future reference. What I typically do is just put whole command ...
4
votes
2answers
303 views

Why am I observing different behaviour of echo?

I am a bash beginner and observed the below behavior of echo #!/bin/bash x=" hello" echo $x echo "$x" Now when I run the above code I get ronnie@ronnie:~$ bash test.sh hello hello ...
0
votes
2answers
159 views

sqlite fts quoting problem

I can do this in sqlite tool: sqlite> select caption from notes_fts where notes_fts MATCH '"perl install"'; but cannot from the Linux shell i.e., this fails: user@host:~$ sqlite3 sqldb ...
1
vote
4answers
186 views

Syntax error in a bash script that calls find

Where is the error in this script please: #!/bin/bash rep="git" files=`find' ${rep} '-type f` for f in ${files} do echo $f done When i run find git -type f alone in the shell, it works!
3
votes
2answers
421 views

how to grep for c:\

I'm using cygwin's grep to find all instances of hardcoded paths on c drive. doing: grep -r "c:\\" . gives grep: trailing backslash Does anybody know how I can do this?
2
votes
3answers
601 views

Is there a way to get *actual* (uninterpreted) shell arguments in a function or script?

I have a function posix that I use in the Git bash shell on Windows to transform DOS-style paths to normal Unix-style paths. Since DOS-style paths use a backslash as separator, I have to quote the ...
0
votes
1answer
229 views

How to run svn when ssh over ssh?

I need to run sudo -u wwwrun sh -c 'svn status -uq /srv/www/htdocs/loquat' over ssh. When using one ssh it works smoothly. Now there is one server that needs to be connected through another server via ...
3
votes
1answer
235 views

Bash script with quotes and spaces

I'm trying to get some nice output out of git: FORMAT='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' LOG_PARAMS="--color --pretty=format:$FORMAT --abbrev-commit ...
1
vote
1answer
77 views

Apostrophe appearing as space

I am trying to insert the following message: friend's mobile number from a file over redhat server into sql server 2005. this message is appearing in the sql server as below: friend s mobile ...
1
vote
2answers
154 views

run bash in script

I want to creat a script to run an another script with a several parameter exp=([1]=bloc [2]=ins [3]=rep [4]=op) for j in ${!exp[*]} do arr=([1]=mem [2]=gen [3]=usr) for i in ${!arr[*]} ...
19
votes
3answers
8k views

What does it mean to have a $“dollarsign-prefixed string” in a script?

I just saw this in an init script: echo $"Stopping Apache" What is that dollar-sign for? My research so far: I found this in the bash manual: extquote If set, $'string' and ...
3
votes
4answers
376 views

Piping paths with different types of quotes for slash substitution

I would like to use sed to convert a path with backslashes to the same path with forward slashes: E.g. I would like to pipe \\path\to\file\ and obtain /path/to/file None of the following commands ...
2
votes
1answer
400 views

Command substitution: file or command not found

The following script #!/bin/bash QUERY='select * from cdr;' MYROWS=$("sqlite3 -list -nullvalue NULL -separator ',' /var/log/asterisk/master.db '${QUERY}'") gives me ./bla.sh: row 35: sqlite3 -list ...
4
votes
2answers
3k views

Passing arguments with quotes and doublequotes to bash script

At this moment I have: #!/bin/bash screen -p 'ScreenName' -x eval 'stuff '"'"$@"'"'\015' echo eval 'stuff '"'"$@"'"'\015' But when I call my script as: # script.sh asd "asd" 'asd' my arguments ...
3
votes
1answer
585 views

Is it a bug for join with -t\t?

I have a problem with the command join. "The default join field is the first, delimited by whitespace" (Cited from join --help). However, there is a field containing sentences in my tab-delimted ...
1
vote
5answers
5k views

bash execute read command from file

After some manipulations, I got the file with commands that I would be glad to be able to execute. Input file (name of file is inp2.txt): "02 - Beautiful Emptiness.mp3" "02 - Come. mp3" "02 - Go ...
-1
votes
1answer
2k views

How to move file from one folder to another in shell script by changing the permission

I want to move a file from one folder to another folder. When the file's format is with space in between (file _name.dat) and when I am using the command mv file _name.dat /tmp then the file is not ...
1
vote
4answers
2k views

Appending a string containing escape character with sed

Currently I use: sed -i -e "5a\\ ${text}" $filename to append something to a certain line, where the variable text contains a string such as "\epsilon". When using echo -E $text the string is ...
4
votes
1answer
636 views

How to run this in sudo?

I have this line that I execute from php sudo -u db2inst1 -s -- "/opt/ibm/db2/current/bin/db2 connect to PLC; /opt/ibm/db2/current/bin/db2 \"update EDU.contact set MOBILE_PHONE = '123'\"" it works ...
12
votes
7answers
739 views

What is the difference between $* and $@?

Consider the following code: foo () { echo $* } bar () { echo $@ } foo 1 2 3 4 bar 1 2 3 4 It outputs: 1 2 3 4 1 2 3 4 I am using Ksh88, but I am interested in other common ...
2
votes
2answers
4k views

Change directory with space followed by '('

There are two directories I can change to: Program Files/ Program Files (x86)/ I can change to first one by writing: cd Program\ Files But the second for second one: cd Program\ Files\ ...
1
vote
2answers
581 views

Weird zsh grep -P behaviour

I connect to server with PuTTY from Windows. I have a long yet not touched (I suppose) by hands of local admin config: $ cat /opt/jira/.subversion/config ... ### must be enabled, which is ...
4
votes
3answers
4k views

Why does bash variable expansion retain quotes?

> echo "hi" hi > VAR='echo "hi"' > $VAR "hi" Why is the output of the above commands different? A similar thing occurs with single quotes: > VAR="echo 'hi'" > $VAR > 'hi'
1
vote
1answer
562 views

Escape text for further passing to zenity

I am going to show an error window using zenity: /usr/bin/zenity --error --text="my error message" The error text to pass is obtained as output from another application. This output may contain ...
5
votes
1answer
153 views

find usage - command line vs script

I am seeing different results from the find command between being run manually on the command line vs run in a script. If I run the following on the command line: find . -name '*.txt' ! -name ...
3
votes
2answers
333 views

issues with GNU tail -f and combination of commands

$ tail -f /logs/filename.log | awk '!(/list)' I am able to run this command in GNU Linux flavour But when I written in a script it is not working. test.ksh: variable="/logs/filename.log | awk ...
33
votes
4answers
70k views

How do I grep for multiple patterns?

I want to find all lines in several files that match one of two patterns. I tried to find the patterns I'm looking for by typing grep (foo|bar) *.txt but the shell interprets the | as a pipe and ...
4
votes
1answer
279 views

printing a string's “canonical print-escaped form”

I'm trying to write a function, I'll call it escape, that will behave like this: % IFS=$' \t\n\000' % escape FOO $IFS FOO=$' \t\n\000' In other words, escape takes two arguments, and then, taking ...
20
votes
2answers
750 views

Why escape trivial characters in shell script?

I just opened a legacy shell script (written in old ksh88 on Solaris) and found the following repeated all throughout the code: [ -f $myfile ] && \rm -f $myfile The escaping backslash ...
3
votes
3answers
535 views

pull out a file named to ~

So I have downloaded a music album from aMule and it is located in the .aMule/Incoming directory. I tried to move it out with the following command: mv albumName.rar ~ This left me with a file ~ ...
4
votes
1answer
215 views

Mutt: can I define my own rules for quoted message detection?

I recently started using mutt with my gmail IMAP mail address. Because I loved it so much, I also set it up with my college email address. This, sadly, is hosted by the college ICT team under ...
2
votes
2answers
411 views

Shell script output incorrectly splitting while being passed as an argument to script

Let's say I have the following two shell scripts: #!/bin/sh #This script is named: args.sh echo 1 "\"Two words\"" 3 , and: #!/bin/sh #This script is named: test.sh echo "Argument 1: "$1 echo ...
14
votes
3answers
7k views

Can't use exclamation mark (!) in bash?

I'm trying to use the curl command to access a http url with a exclamation mark (!) in its path. e.g: curl -v "http://example.org/!287s87asdjh2/somepath/someresource" the console replies with bash: ...
1
vote
3answers
1k views

How can we rename a file with semi-colon as part of the filename?

I tried to rename all file with extension "XLS;1" to "XLS" but it just didn't work. I tried the following in cygwin in windows xp and they don't work: mv *.XLS;1 *.XLS mv *.XLS\;1 *.XLS mv ...
21
votes
3answers
44k views

What characters do I need to escape when using sed in a sh script?

Take the following script: #!/bin/sh sed 's/(127\.0\.1\.1)\s/\1/' [some file] If I try to run this in sh (dash here), it'll fail because of the parentheses, which need to be escaped. But I don't ...
0
votes
1answer
415 views

Shell script to check server state

I am writing a script that would ssh into the VMWare server and check if the VMs are up or not. There's some error in the server=awk "/$i/{print $2}" /home/dharmit/scripts/vmids line. I am getting ...
7
votes
2answers
1k views

Number of backslashes needed for escaping regex backslash on the command-line

I recently had trouble with some regex on the command-line, and found that for matching a backslash, different numbers of characters can be used. This number depends on the quoting used for the regex ...
27
votes
3answers
5k views

using single or double bracket - bash

I'm confused with using single or double bracket. look at code: dir="/home/mazimi/VirtualBox VMs" if [[ -d ${dir} ]]; then echo "yep" fi It works perfectly although the string contains space. ...
3
votes
1answer
7k views

grep and escaping a dollar sign

I want to know which files have the string $Id$. grep \$Id\$ my_dir/mylist_of_files returns 0 occurrences. I discovered that I have to use grep \$Id$ my_dir/mylist_of_files Then I see that the ...
1
vote
2answers
838 views

Issue with mv command in a script

This must be a very simple issue to solve, but I am stuck (not a UNIX pro). I need to move a gz to a target directory, but I get a No such file or directory. NOW=$(date +"%Y-%m-%d-%T") ...
4
votes
1answer
607 views

Calling script from bash has problem with arguments

I have a script that generates an xml file and then executes a perl script, passing a series of arguments to it. Here's the key code: CMD="./dnscurl.pl --keyname $KEYNAME -- -X POST -H ...
19
votes
1answer
4k views

How can I execute `date` inside of a cron tab job?

I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use: 0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log ...
2
votes
3answers
288 views

man xargs says standard input is delimited by blanks; but is it?

I'm puzzled by what actually defines an arg in xargs. The man page seems to suggest that args are delimited by blanks (I assume that means whitespace). However the following script doesn't behave as ...