shell-scripting

mysql dump selection of databases (not sure how many)

I would like to create a backup script (.sh that I can cron) that backs up the following databases: someotherdatabase database1 database2 database3 database4 database5 database6 ... database9999 I know "someotherdatabase" will always have that name so that can be backed up easily. The other databases have an incremental number but I d...

How to define constants in fish?

In sh: readonly constant=value How to do it in fish? ...

Shell Script to monitor folder and upload found files via FTP

Hi everyone! I'm in a need of a shell script that search for all files in a folder, move all those files to a temp folder, and upload those files via FTP. When the file transfer via FTP completes successfully, the file is moved to a completed folder. In case any of those files fails, the file will be moved to a failed folder. I have v...

How to extract a value from a string using regex and a shell?

I am in shell and I have this string: 12 BBQ ,45 rofl, 89 lol Using the regexp: \d+ (?=rofl), I want 45 as a result. Is it correct to use regex to extract data from a string? The best I have done is to highlight the value in some of the online regex editor. Most of the time it remove the value from my string. I am investigating expr, ...

Shell Scripting: Using xargs to execute parallel instances of a shell function

I'm trying to use xargs in a shell script to run parallel instances of a function I've defined in the same script. The function times the fetching of a page, and so it's important that the pages are actually fetched concurrently in parallel processes, and not in background processes (if my understanding of this is wrong and there's negli...

(unix shell scripting) Trim last 3 characters of a line WITHOUT using sed, or perl, etc.

Hi, I've got a shell script outputting data like this: 1234567890 * 1234567891 * I need to remove JUST the last three characters " *". I know I can do it via (whatever) | sed 's/\(.*\).../\1/' But I DON'T want to use sed for speed purposes. It will always be the same last 3 characters. Qny quick way of cleaning up the output? ...

Combining tab delimited files based on a column value

Suppose I have two tab-delimited files that share a column. Both files have a header line that gives a label to each column. What's an easy way to take the union of the two tables, i.e. take the columns from A and B, but do so according to the value of column K? for example, table A might be: employee_id name 123 john 124 mary a...

[javascript] EXTENDS challenge: preprocessor function macros and class-like oop

Background I've been using the C preprocessor to manage and "compile" semi-large javascript projects with multiple files and build targets. This gives full access to C preprocessor directives like #include, #define, #ifdef, etc. from within javascript. Here's a sample build script so you can test the example code: #!/bin/bash export OP...

Delete strings from an html file containing a pattern using unix commands

Hi, I have a messy html that looks like this: <div id=":0.page.0" class="page-element" style="width: 1620px;"> <div> <img src="viewer_files/viewer_004.png" class="page-image" style="width: 800px; height: 1131px; display: none;"> <img src="viewer_files/viewer_005.png" class="page-image" style="width: 1600px;"> </div> </div>// this ...

How to "flip-replace" strings in a file using shell scripting

Hello, I am facing the following problem. Let's say I have a file, which contains something like this: blah blah blah blah more text <tag1>something</tag1> <tag2>something else</tag2> blah blah meh whatever foo bar What I want to do is to replace all occurrences of tag1 with tag2, and all occurences of tag2 with tag1. However, I don'...

gzipping up a set of directories and creating a tar compressed file

My bash fu is not what it should be. I want to create a little batch script which will copy a list of directories into a new zip file. There are (at least) two ways I can think of proving the list of files: read from a file (say config.txt). The file will contain the list of directories to zip up OR hard code the list directly into ...

##*/ use in UNIX Shell Scripting

Hi, Could anyone eloborate how ##*/ works in UNIX Shell scripting. I have seen it's use in Korn Shell. It is specifically used for removing extension of file. e.g. func_write_app_log "o Deleting status file ${CIE_STATUS_FILE##*/}" Here suppose the file is CIE_STATUS_FILE.DAT, then ##*/ will display CIE_STATUS_FILE ...

Periodic Script- Daemon-

Hi i have hp-ux and i need delete a specific file every day. then I need to do a shell script or something else with a simple command for example # rm <filename> But i need add this script to init, or convert this script in daemon TO GRANT that every day at 20:00, this script run and delete the file. I guess that the above is the pro...

Deliver test params using adb shell am start command

Hi All I wish to know how in java I should receive these parameters. I do know how to deliver parameters via adb shell am start command but I still have a problem to get them in java (android) code. My class extends InstrumentationTestCase and not Activity class!!! So I cannot perform: this.getIntent(). I anderstand that I need...

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, ...

Add a Ubuntu User from Web Interface

Hi, I have been tasked with the job of creating a web based system to add system users to our Ubuntu linux server. I have been reading up online, and there seems to be a fair few different ways to go about doing it, none of which really have examples. I understand the best way for me to do it would be to temporary give sudo to the apac...

shell script to c converter

Does anyone know of any tool which can convert shell script '.sh' into a C file '.c' ? ...

How to connect to the inbox of a mail like gmail or yahoo etc using a shell script??

We have a database, and we data into database from diferent sources . One source sends data through an email. I have to write a shell script in such a way , that it establishes a connection with that mail (eg: gmail) and acess the inbox of that mail. If possible converts the recent mails in the inbox to text format. Kindly help me plea...

Dialog --input box

dialog -- input box this command is taking only one input at a time is there any way to take multiple inputs from user at a time for eg ask name roll no rank as a input at same time ...

Shell script to get difference in two dates

If there are dates as 2010-06-01 and another as 2010-05-15 Using shell script or date command how to get the number of days between the two dates Thanks.. ...