bash

bash script: get just filename from path

How would I get just the filename without the extension and no path? The following gives me no extension but I still have the path attached: source_file_filename_no_ext=${source_file%.*} ...

until command_is_finished; do ...

Hello, I want to be able to echo some stuff (i.e. a spinner) as long as a command (a database dump to be precise), is still running. Because right now, it's like 15 minutes of: "is my script still running?" Suggestions in bash? while? until? Thanks, ...

Consuming bandwidth

Dear Community, I know how to write a basic bash script which uses wget to download a file, but how do I run this in an endless loop to download the specified file, delete it when the download is complete, then download it again. ...

Matching lines across multiple csv files and merging a particular field

I have about 20 CSV's that all look like this: "[email]","[fname]","[lname]","[prefix]","[suffix]","[fax]","[phone]","[business]","[address1]","[address2]","[city]","[state]","[zip]","[setdate]","[email_type]","[start_code]" What I've been told I need to produce is the exact same thing, but with each file now containing the start_code...

Using Until to Restart a Process when it dies

I read this Question: "How do I write a bash script to restart a process if it dies". A solution is to: until myserver; do echo "Server 'myserver' crashed with exit code $?. Respawning.." >&2 sleep 1 done Will this work for Tomcat/Jetty processes that are started from a script? Do I test the success with "kill" to see if ...

how to see the content of a particular file in .tar.gz archive without unzipping the contents?

for ex abc.tar.gz has abc/file1.txt abc/file2.txt abc/abc1/file3.txt abc/abc2/file4.txt i need to read/display the contents of file3.txt without extracting the file. Thanks for any input. ...

iPhone - Execute iphone app from documents folder

Hi all, I'm writing an app which must download other apps and EXECUTE them from the documents folder. One of the approaches I was thinking about is to use a bash script like the one in installous which unzips the app and copies whatever whenever it's needed.That way I can install it,but not execute it. So I was wondering if there is a ...

How can I recall the argument of the previous Bash command?

Is there a way in Bash to recall the argument of the previous command? I usually do vi file.c followed by gcc file.c. Is there a way in Bash to recall the argument of the previous command? ...

Continue output on same line

Hello, Want to do a fancy effect by printing [OK] at the end of the last line when a task is finished. Got this: echo "$0: Starting backup process in '$backupdir'... " sleep 3 echo '[OK]' I tried different things at the end of the first echo, at the beginning of the second like \r, \c, \, Googled it... No good. I want it to output...

Get name of directory wher script is executed

Hello, I have some script, that uses files in directories around it. It uses dirname $0 command. And it should work from any directory from where I will run this script, but when I run symbolic link that points to that script, I get the path of symbolic link like an output of dirname rather than the path of the script itself. Any on...

perl backticks: use bash instead of sh

Hi, I noticed that when I use backticks in perl the commands are executed using sh, not bash, giving me some problems. How can I change that behavior so perl will use bash? PS. The command that I'm trying to run is: paste filename <(cut -d \" \" -f 2 filename2 | grep -v mean) >> filename3 ...

Bash script for outputting directory details to a file

Hi all, I am trying to write a simple bash script that will search for files with a certain extension in a directory. Then output all those files with full path in front. For example, if I have a directory with many different file types, but I want to know the information about those with only the .txt extension. How can I get the ou...

How to find the biggest element and store it in array

I have file as shown below .I have to find the maximum value for each timestamp. So I have to find the max(2434, 2681, 2946, 1626) , max(3217, 4764, 4501, 3372) and so on ... (since these numbers have a common timestamp) Timestamp value 1280449531 2434 1280449531 2681 1280449531 2946 1280449531 1626 1280449532 3217 1280449532 4764 128...

Need to patch using a string/variable

I am writing a script to automate the process of setting up a bunch of Mac's in a computer lab. Each system is uniquely identified and I need a method of patching a plist file in several locations with the same string that will be read from the user in the script which is a bash script The original string is always the same. The patchi...

Can stdout, stderr always tee to a regular file?

Howdy, Can I configure bash on Linux to write a copy of all stdout and stderr to a regular file, without having to specify the redirection for each command? Thanks, Kent ...

Batch converting videos in folders and sub folders

I have a huge collection of videos that all need to be converted into mp4. The folder structure is like this Events Chicago Boston San Fran London Expo Inside each event holds all of videos in either avi format or .mkv. I want them to be converted to the same file name. but with the mp4 extension. My question is how do I loop...

how to pass keyboard input along to linux command ?

I run a linux command that sometimes asks for user input (press 1 or 2). I always want to answer 1, how can I pass this value automatically ? ...

Minor issue with bash scripting to make a function accept all arguments after initial function call as a single string.

I'm trying to write a simple bash script that accepts all arguments and interprets them simply as a string. In other words: tweet Testing out my command-line tweetings. #commandlinetweets Takes in all the arguments and just uses them bluntly as a string. Here is the basic form that I have at the moment: function tweet() { echo "Twee...

spawn terminal reading its stdin

Hi all, I'm writing (under linux or windows+cygwin) a java program that needs to run a command (process P1) and read its stdout (which is mostly binary data useful to my program). This is easy to do, and already done. The problem is that P1 also prints some status informations on stderr, and I would like to spawn a terminal (like xter...

How can I "look behind" the bash command line argument expansion?

I want a Perl script to accept wildcards (foo-*.ba?) for file names (which are then processed for a whole directory subtree). Of course, I can tell the users of my script to quote the argument ('foo-*.ba?'), but this is not really elegant - the wildcard method is meant as a user-friendly alternative to passing regexes (which are accepte...