Code:
lyang0@lyang0-OptiPlex-755:~$ ./test.sh
.
lyang0@lyang0-OptiPlex-755:~$ cat test.sh
#!/bin/bash
echo `dirname $0`
lyang0@lyang0-OptiPlex-755:~$ pwd
/home/lyang0
it doesn't get "/home/lyang0" and only when run /home/lyang0/test.sh it will get, but how can I do, then it can get the real full path anytime?
Hi expert
The delete the 2th
Code:
lyang0@lyang0-OptiPlex-755:~/del$ sed 's/[a-zA-Z]*//2p' 9
to delete from 2th
Code:
lyang0@lyang0-OptiPlex-755:~/del$ sed 's/[a-zA-Z]*//2gp' 9
but if I want to delete 2th 3th 4th
or
but if I want to delete 2th 15th
how could I do?
Code:
lyang0@lyang0-OptiPlex-755:/tmp$ ./fg.sh
...............................
ssh to the guest .....
...............................
./fg.sh: 18: :ls: not found
Code:
lyang0@lyang0-OptiPlex-755:/tmp$ cat fg.sh
#!/bin/sh
DEFAULT_CMD="ls /boot/"
ssh_to_guest()
{
echo "..............................."
echo &quo
toys
This one's a very close variation on Print a horizontal line (credit goes to those guys). You may wish to read it first, as well as The printf command. We're basically exploiting the same printf field width specifier concept to truncate the values of a sequence expansion.
I need a command line script that will generate a random integer between 1 and 6. I'm using Ubuntu with bash.
I was working on this a couple of months ago using 'bc', but never got it to work completely. I've since forgotten where I got to.
I'm getting weird syntax's like
print ""
Syntax Error: invalid syntax
also getting
time.sleep(1)
Syntax Error: invalid syntax
elif skill==2:
Syntax Error: invalid syntax
Code:
#Another version of the "adventure game"
#September 14, 2012
import random, os, time, string
os.system("color 1C") # green(2) text on white(F) background
#Warr
First off, here is a fast / reliable random string function for scripts or libraries which can optionally assign directly to a variable.
# Print or assign a random alphanumeric string of a given length.
# rndstr [ -v var ] len
# Bash-only
rndstr()
if [[ $FUNCNAME == "${FUNCNAME[1]}" ]]; then
# On recursion, this branch unsets the outer scope's locals and assigns the result.
How can I use /dev/(u)random on Ubuntu or any *nix sistems ?
I searched at google but I can't find how to :(
I tried this but it says permission denied.
Note : I also tried as root.
/dev/(u)random
sudo /dev/(u)random
sudo -s;/dev/(u)random
Solution :
dd if=/dev/urandom of=~/urandom_test count=4 bs=1024
First off, here is a fast / reliable random string function for scripts or libraries which can optionally assign directly to a variable.
# Print or assign a random alphanumeric string of a given length.
# rndstr len [ var ]
function rndstr {
if [[ $FUNCNAME == "${FUNCNAME[1]}" ]]; then
unset -v a
printf "$@"
elif [[ $1 != +([[:digit:]]) ]]; then
return 1
elif