On a GNU system I would just use readlink -f $SOME_PATH, but Solaris doesn't have readlink.
I'd prefer something that works well in bash, but other programs are ok if needed.
Edit: The best I've come up with so far uses cd and pwd, but requires some more hackery to deal with files and not just directories.
cd -P "$*"
REAL_PATH=`pwd`
...
Let's say I have a list of ip's coming into a log that i'm tailing
1.1.1.1
1.1.1.2
1.1.1.3
etc..
and i'd like to easily resolve them to host names. I'd like to be able to
tail -f access.log | host -
Which fails as host doesn't understand input from stdin in this way. What's the easiest way to do with without having to write a sta...
I have a text file with various entries in it. Each entry is ended with line containing all asterisks.
I'd like to use shell commands to parse this file and assign each entry to a variable. How can I do this?
Here's an example input file:
***********
Field1
***********
Lorem ipsum
Data to match
***********
More data
Still more data
*...
I’m stuck in trying to grep anything just after name=, include only spaces and alphanumeric.
e.g.:
name=some value here
I get
some value here
I’m totally newb in this, the following grep match everything including the name=.
grep 'name=.*' filename
Any help is much appreciated.
...
Is there a way to parse input and output from bash commands in an interactive terminal before they reach the screen ? I was thinking maybe something in .bashrc, but I'm new to using bash.
For example:
I type "ls /home/foo/bar/"
That gets passed through a script that replaces all instances of 'bar' with 'eggs'
"ls /home/foo/eggs/" gets...
There is an example of "how to do this" on Stuart Colville's blog, but the example used there and the explanation of why it works is unclear.
To keep things simple:
Let's say you have a bash alias like
alias rxvt='urxvt'
which works fine.
alias rxvt='urxvt -fg '#111111' -bg '#111111''
won't work, and neither will:
alias rxvt='u...
cat /dev/urandom is always a fun way to create scrolling characters on your display but in that output, there is too many non character output.
now i was thinking, is there an easy way to encode on the commandline it in such way that all of itś output are readable characters, base64 or uuencode for example.
note that i prefer solutions...
Hi!
I'm trying to make a bash script in linux where some encrypted data is embedded and then retrieved and decrypted with openssl, like this:
cat | openssl des3 -d -a -salt -pass pass:asdf > output.txt <<EOF
U2FsdGVkX1/zN55FdyL5j1nbDVt5vK4V3WLQrnHPoycCJPwWO0ei3PCrrMqPaxUH.....blablablah data
EOF
The only problem with this, that would...
I have several thousand ebooks that need to be organized on a headless linux server running bash through SSH. All of the ebooks are thankfully named with one of 2 conventions.
AuthorFirstName AuthorLastName - Book Title.pdf
AuthorFirstName AuthorLastName - Book Series #inSeries - Book Title.pdf
i.e.
Andrew Weiner - Changes.pdf
Allan ...
Should the name of command line options for a program in a POSIX-style operating system be underscore-style, like
--cure_world_hunger
or maybe some other style?
--cureworldhunger
--cure-world-hunger
--cureWorldHunger
What's most common? What's better style? What's more Bash-friendly (if such a thing exist)?
...
Hi! Is there an opportunity to convert a string into a date in bash? For example: I have a time format: "%Y-%m-%dS%H:%M:%S". An example of such string is "2009-06-24S12:34:56". I need to convert this string into a date (unix timestamp) in bash. How can I do this?
...
I know it's really stupid question, but I don't know how to do this in bash:
20 / 30 * 100
It should be 66,67 but expr is saying 0, because it doesn't support float.
What command in Linux can replace expr and do this equalation?
...
How can you get similar highlightings to Zsh's Less than Bash's Less in Ubuntu?
I switched from OS X to Ubuntu. My Less do not work as expected in Zsh.
Manuals in my Less are green and black with or without the following code.
# comment these out in Ubuntu
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
exp...
I am running bash in emacs on osx and its pulling gems from a different place then terminal.app
in bash:
which gem
/usr/bin/gem
in terminal:
which gem
/opt/local/bin/gem
How do I change the bash to match terminals?
...
Im completely new to Bash scripting but I've been told, with little help, to create a file that compresses textures into PVR format only if the file has been modified since the last time the script was run. Heres the code I have so far:
# variables
TEXTURE_TOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool
INPUT...
I've created a small Bash script that does a MySQL data dump. Because the dump can be fairly large I put the process in the background and then wait for either an error or the log to show up in the file system. I have the following code:
mysqldump main_db > /loc/to/dmp/file.sql 2>/loc/to/error/log/file.log &
The problem is that I get ...
Hi all,
I'm sure this question may seem foolish to some of you, but I'm here to learn.
Are these assumptions true for most of the languages ?
EDIT : OK, let's assume I'm talking about Perl/Bash scripting.
'Single quotes'
=> No interpretation at all (e.g. '$' or any metacharacter will be considered as a character and will be printed ...
I am working on a bash script that needs to take a single line and add it to the end of a file if it exists, and if it does not exist create the file with the line.
I have so far:
if [ ! -e /path/to/file ]; then
echo $some_line > /path/to/file
else
???
fi
How do I perform the operation that should go in the else (adding the...
Hi,
This keeps happening to me all the time:
1) I write a script(ruby, shell, etc).
2) run it, it works.
3) put it in crontab so it runs in a few minutes so I know it runs from there.
4) It doesnt, no error trace, back to step 2 or 3 a 1000 times.
When I ruby script fails in crontab, I can't really know why it fails cause when I pipe o...
We have a very simple tcp messaging script that cats some text to a server port which returns and displays a response.
The part of the script we care about looks something like this:
cat someFile | netcat somehost 1234
The response the server returns is 'complete' once we get a certain character code (specifically &001C) returned.
H...