bash

Combine two particular lines using sed

I have the following input file that you might recognize as a debian Packages file: Package: nimbox-apexer-sales Version: 1.0.0-201007241449 Architecture: i386 Maintainer: Ricardo Marimon <[email protected]> Installed-Size: 124 Depends: nimbox-apexer-root Filename: binary/nimbox-apexer-sales_1.0.0-201007241449_i386.deb Size: 68880 MD5...

How to find time in sh scripting

I'm trying to find a way to get date and time separately. For date I can do: date -u +%d/%m/%Y What should I do to find the time in the following format? hh/mm/ss Thanks ...

Shell script : How to cut part of a string

Hello, I have following string â â³ eGalax Inc. USB TouchController id=9 [slave pointer (2)] â â³ eGalax Inc. USB TouchController id=10 [slave pointer (2)] and would like to get the list of id ? How this can be done using sed or something else ? Regards, Levon ...

Whats wrong with this bash script?

$ cat fav #!/bin/bash for i in {1..7} do echo http://api.stackoverflow.com/1.0/users/113124/favorites?page=$i&amp;pagesize=100 done $ ./fav http://api.stackoverflow.com/1.0/users/113124/favorites?page=1 http://api.stackoverflow.com/1.0/users/113124/favorites?page=3 http://api.stackoverflow.com/1.0/users/113124/favorites?page=6 http:...

How to get the contents of a webpage in a shell variable ?

In Linux how can I fetch an URL and get its contents in a variable in shell script? ...

RegEx in bash-script (for-loop)

I want to parse the arguments given to a shell script by using a for-loop. Now, assuming I have 3 arguments, something like for i in $1 $2 $3 should do the job, but I cannot predict the number of arguments, so I wanted use an RegEx for the range and $# as the number of the last argument. I don't know how to use these RegEx' in a for-loop...

Makefile - Why is the read command not reading the user input???

I have the following code inside a Makefile: # Root Path echo "What is the root directory of your webserver? Eg. ~/Server/htdocs" ; read root_path ; echo $root_path ; if [ ! -d $root_path ] ; then \ echo "Error: Could not find that location!" ; exit 1 ; \ fi However when typing anything (eg. "asd") this is what gets returned: Wha...

Call a shell script in java?

Hey, is it possible to call a shellscript or the shellcode in a java class? My Code (in a static method): Runtime rtime = Runtime.getRuntime(); Process child = rtime.exec("/bin/bash"); BufferedWriter outCommand = new BufferedWriter(new OutputStreamWriter(child.getOutputStream())); outCommand.write("streamer -c /dev/video0 -b32 -o test...

Find and replace date/time in string

I have already made a regex which should work, but it doesn't work. echo "FileName.17:09:2010 4.16.PM.720p.mp4" | sed -E 's/\d{2}:\d{2}:\d{4}\ (\d|\d{2})\.(\d{2}|\d)\.((AM)|(PM))//g' Should output: FileName..720p.mp4 But instead outputs the same "FileName.17:09:2010 4.16.PM.720p.mp4". ...

Hook up into another Terminal process?

I've got two terminal instances/processes opened with different PID. Is it possible to from one of them, hook up into the other so when I type something and it outputs something, then the other terminal will see the output too (maybe the input too if possible?). Just like cloning the terminals. I want this because then I can hook up s...

Execute commands inside another process?

I want to be able to start a process and send input to it immediately. Take Bash as an example. The following code will enter another Bash process and then print "Hello World!" on the screen after I have terminated the process with "exit" bash echo "Hello World!" Is there a way to enter bash and then print "Hello World!" INSIDE that...

Ruby version of the TCL-based Expect?

Expect seems to be a very powerful automation tool: http://www.nist.gov/mel/msid/expect.cfm Is there a Ruby equivalent to that tool? ...

Shell script with whitespace in path executes differently depending on directory

I have made a script to open Spotify with wine: #!/bin/bash DIR="/home/jorgsk/.wine/drive_c/Program Files/Spotify/" cd "$DIR" wine spotify.exe 2>/dev/null I'm passing "$DIR" to cd with quotes because of the whitespace in "Program Files"; if I don't have the quotes "/home/jorgsk/.wine/drive_c/Programs" will be considered as the argumen...

regexp in bash (downloading output form regexp)

I have got a file that look like: <a href="some-adress">some-txt</a> <a href="some-adress">some-txt</a> <a href="some-adress">some-txt</a> ... I need to download all files that are as "some-adress", how can I do that using only bash? ...

bash filename start matching

Hello, I've got a simple enough question, but no guidance yet through the forums or bash. The question is as follows: I want to add a prefix string to each filename in a directory that matches *.h or *.cpp. HOWEVER, if the prefix has already been applied to the filename, do NOT apply it again. Why the following doesn't work is somethi...

get just the integer from wc in bash

Is there a way to get the integer that wc returns in bash? Basically I want to write the line numbers and word counts to the screen after the file name. output: filename linecount wordcount Here is what I have so far: files=`ls` for f in $files; do if [ ! -d $f ] #only print out information about files !directories then...

Expect works great interactively but not from file

It works great when I use expect interactively like this: root@vagrantup:/home/vagrant> expect -i expect1.1> spawn screen -x spawn screen -x 3195 expect1.2> send "ls\n" expect1.3> exit But the same commands used in a file: spawn screen -x send "ls\n" exit Only works sometimes, eg. 1/10 time every time I execute the file. It's reall...

Regular expression for filtering out JS + iframe

Hi, I'm looking for regular expression that will filter out: javascript: <script></script> and everything that is in between in between javascript also contains: iframe and hostads.cn url Thanks. I plan to use that regexp in simple bash script that will remove part of the code from the files in the directory. ...

ffmpeg run from command line executes, from mod_fcgi truncates after completion

The ffmpeg from command line generates preview files and two separate two-pass conversion that when run from a shell script, execute successfully. Running the commands via php's exec(/usr/bin/ffmpeg) or through exec(name_of_shell_script) generates preview files successfully. THe strange behavior is that the movies will generate, then ...

Insane crond behavior. keeps making defunct bash processes

I have a crontab that looks like: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ 0-59 * * * * /var/www/html/private/fivemin/zdaemon.php >> /dev/null & Simple as possible, right? zdaemon.php which I am just testing with is: #!/usr/bin/php <? while(true){ sleep(1); } ?> Whenever it runs it hangs li...