I am trying to parse the "number of hops" value from the traceroute command and output it with a bash script.
Any hints? Very new so thanks.
My script looks like this so far:
#!/bin/bash
#parse traceroute for hops and output to stdout.
echo -n "Enter a host name(like www.google.com): "
read hostname
traceroute 2>&1 $hostname|grep "...
How can I print the output to terminal and file at the same time?
$ perl foo.pl > foout.txt
does not allow me to see live process.
Is there any way I can see the output process real time and getting at the end the output of the screen on a file?
...
I am trying to call a bash command through a user account with PsExec. Cygwin is being used, and I am trying to run a command from SQL:
exec master..xp_cmdshell 'psexec -u cyg_server -p <pwd> -accepteula "bash script.sh"';
However, I get the following error from psexec:
Access is denied.
PsExec could not start bash script.sh...
Hi All,
I have a few little scripts that I use for monitoring some aspects of our application that reside in an infinite loop with a 3 second sleep and simply display the output of ps aux | grep -i app_name or mysql -e "SHOW SLAVE STATUS\G" just so I can easily watch for a few mins without hitting any keys, what I'd like to know is how ...
I am looking for a bash or sed script (preferably a one-liner) with which I can insert a new line character after a fixed number of characters in huge text file.
...
I have inherited a shell script. One of the things it does is parsing of a list of filenames. For every filename in the list it does following command:
fs_item="`echo ${fs_item%/}`"
This command (a part from doing it's job which in this case, I think, is to remove everything after last slash) replaces spaces in filename with one space...
I have a java program that I would like to be able to run from anywhere on my machine. I would like to run it from my Cygwin command prompt. I've made scripts to call the java program. I added the location of the java program to the classpath, and the scripts work when I run them from the java program's directory. However, when I try...
is there a tool out there similar to Javadoc or POD for shell scripting?
thanks
EDIT: I am not looking for existing shell man pages - there is a lot of ksh/bash code we write/support, so I was looking for a nice way to communicate what's happening, whether there is a potential for code reuse, etc. all things Javadocs are good for.
...
we all create/discover new and useful commands every day (I do...) but I forget them the day after, above all those complicated command pipes.. I use history | grep but that's not enough.
I'd like a program to save and categorize my favorite commands, that lets you search them and execute them easily.
If you know any, that'd be cool
if...
I tried to insert a text to the first line
of a file using sed. I do this inside a bash
script.
But why it hangs at the line of sed execution?
#! /bin/bash
# Command to execute
# ./mybashcode.sh test.nbq
nbqfile=$1
nbqbase=$(basename $nbqfile nbq)
taglistfiletemp="${nbqbase}taglist_temp"
taglistfile="${nbqbase}taglist"
./myccod...
Hi,
cmake advises to use out-of-source builds. While in general I like the idea I find it not comfortable to navigate from out-of-source sub directory to the corresponding source directory. I frequently need the code to perform some actions with code (e.g. grep, svn command etc.).
Is there an easy way in shell to navigate from out-of-s...
I want to check if my string contain one or more asterisk.
I have tried this :
if [[ $date_alarm =~ .*\*.* ]]
then
...
fi
It worked when I launch directly the script, but not if this script is called during shutdown (script installed in run level 0 and 6 via update-rc.d)
Any idea, suggestion ?
Thanks
...
How to generate a random number in bash?
...
I have a java CLI script that converts rgb names to hexcodes (e.g. 144 132 146 becomes #908492). However, I want to be able to run it from any terminal. I put a bash script in the same folder so it could run the file:
The bash script is simple enough, just:
#!/bin/bash
java rgb2hexConv $1 $2 $3
However, when I run the code through th...
How can I take any given path in bash and convert it to it's canonical form, dereferencing any symbolic links that may be contained within the path?
For example:
~$ mkdir /tmp/symtest
~$ cd /tmp/symtest/
/tmp/symtest$ mkdir -p foo/bar cat/dog
/tmp/symtest$ cd foo/bar/
/tmp/symtest/foo/bar$ ln -s ../../cat cat
/tmp/symtest/foo/bat$ cd ....
Hi,
I am trying to execute a command remotely over ssh, example:
ssh <user>@<host> <command>
The command which needs to be executed is an alias, which is defined in .bashrc, e.g.
alias ll='ls -al'
So what in the end the following command should get executed:
ssh user@host "ll"
I already found out that .bashrc only gets sourced w...
I'm writing a bash script to get data from procmail and produce an output CSV file.
At the end, I need to translate from this:
---label1: 123456
---label2: 654321
---label3: 246810
---label4: 135791
---label5: 101010
to this:
label1,label2,label3,label4,label5
123456,654321,246810,135791,101010
I could do this easily with a ruby s...
Hi, I am new to bash. I need to write the script which executes the following commands consecutively
su - bbt; id
and to see the result.
I have tried to put this line into the tmp.sh and then run it.
I just see the results of the first command su - bbt. I don't see the results for the id command.
...
In my bash script I need to extract just the path from the given URL.
For example, from the variable containing string:
http://login:[email protected]/one/more/dir/file.exe?a=sth&b=sth
I want to extract to some other variable only the:
/one/more/dir/file.exe
part. Of course login, password, filename and parameters are optional...
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.10
DISTRIB_CODENAME=intrepid
DISTRIB_DESCRIPTION="Ubuntu 8.10"
This is the server version.
When I ssh into it, I encounter the following problems:
Problem 1
tab completion behaves weird to the point of being unusable:
> cd ~/<press TAB>
-sh: <( compgen -d -- '/home/dmitriid/' ): No such file or d...