Hi,
I've known several operations we can do to variables in shell, e.g:
1) "#" & "##" operation
with ${var#pattern}, we remove "pattern" in the head of ${var}. "*" could be used in the pattern to match everything. And the difference between "#" and "##" is that, "##" will remove the longest match substring while "#" removes the shorte...
Given that there is a file called copystuff in the Resources folder in a an xCode project, and that file reads:
#!/bin/sh
cp -R /Users/someuser/Documents /Users/admin/Desktop
And if this bit of code below is linked to a button in IB ... it will copy the /Users/someuser/Documents directory to /Users/admin when the button is pressed in ...
Within a python script, I want to issue a command. In perl, I could define a command, save it as a variable (here, $cmd) then type system($cmd) and then the command is executed.
How can i do that in python?
...
While writing a bash script to help creating polaroid thumbnail using Imagick's convert commmand. I encounter a problem. Although, I manage to work around with this (actually, because convert is flexible enough), I still want to know how to solve this without such specific workaround.
So basically, the bash script will get a caption val...
I want append to a string so that every time I loop over it will add say "test" to the string.
Like in PHP you would do:
$teststr = "test1\n"
$teststr .= "test2\n"
echo = "$teststr"
echos:
test1
test2
But I need to do this in a shell script
...
When using MSYS on a windows platform, I "set -o vi" to use the vi shell mode. Tab autocompletion for files and directories stops working. How to I renable this while remaining in vi shell mode?
...
I am catching emails to "script@localhost" with /etc/aliases:
script: root,"|/path-to-my-script"
this gets an email on STDIN and I am parsing and passing it to other scripts.
#!/usr/bin/ruby
email = ARGF.read
...parse...parse-some-more...
system("/my-other-script.sh #{email.todo}")
the question is - what would be a best way to ca...
Dear Masters of The Command Line,
I have a directory tree for which I want to generate a file that contains on two entries per line: full path for each file and the corresponding privileges of said file.
For example, one line might contain:
/v1.6.0.24/lib/mylib.jar -r-xr-xr-x
The best way to generate the left hand column there appe...
I would like to save ApacheBench (ab) tool on linux to a file. When I run it with -v 2 it displays some results in my ssh window. How to move these data into a file and make sure that it will not display on ssh no more? I've tried > file.txt but it does not work and still display data in my ssh window.
...
In a bash shell on linux, if I type:
echo $DISP
and hit tab, it completes to:
echo $DISPLAY
It doesn't work in bash on OSX 10.5, and I'm using the same .bashrc
Is there a shell option or setting I can use to set this.
...
I have a number of modules in CVS with different tags. How would I go about getting the name of the branch these tagged files exist on? I've tried checking out a file from the module using cvs co -r TAG and then doing cvs log but it appears to give me a list of all of the branches that the file exists on, rather than just a single branch...
I'm using
sed -e "s/\*DIVIDER\*/$DIVIDER/g" to replace *DIVIDER* with a user-specified string, which is stored in $DIVIDER. The problem is that I want them to be able to specify escape characters as their divider, like \n or \t. When I try this, I just end up with the letter n or t, or so on.
Does anyone have any ideas on how to do this...
'man uniq' documents the -f=N and -s=N options which make uniq skip the first N fields/characters respectively when comparing lines, but how would you force uniq to skip the last N fields/characters?
...
I have a client and a host program (written in c) which I want to run from two different remote locations simultaneously. Since I have to do this some 50 times to gather data, I don't want to have to run them individually. On one side, I need to log in via ssh, start the script and tell it to write the output to a file. Then I need to...
Hi, I'm writing a little script, that will create archives in main thread and after each archive is complete, a new thread would be created by calling function that would take care of uploading these archives. The reason I want uploading to be done in background is so that another archive could be created while the previous archives are ...
hello
Is it possible to use emacs bindings in bash shell with numeric arguments, for example in emacs C-u 5 C-d deletes five characters. Is there an equivalent way of doing the same in bash prompt?
Thanks
...
Hello again! I need a way to replace HTML ascii codes like ! with their correct character in bash. Is there a utility I could run my output through to do this, or something along those lines?
Thanks!
...
Hi,
Is there a way in bash shell scripting so that I can convert a string into lower case string. For example,
if $a = "Hi all"
I want to convert it to
$a = "hi all"
Thanks a lot for your help
...
I have a bashscript that spawns processes on two different machines over ssh and then cat's the output of one into a text file. How can I have the output ALSO displayed in the terminal as it's running?
...
when I run it in the terminal (bash)
echo -e ."\c"
prints out . and suppresses the newline.
When I run the following script (all the code)
echo -e ."\c"
echo -e ."\c"
it prints out .. and suppresses the newlines.
when I run it inside a script with the shebang (!#/bin/sh), it prints out -e . -e . and suppresses the newline.
Why? ...