shell

Redirect output of shell script to a file

I'm trying to redirect the output of my script and it needs to be called inside the script. filename=uname -a filename="$filename" date 2>&1 | tee $filename".txt" That is what I have so far, but it's obviously wrong. I don't know too much SH scripting, so help is appreciated -Alex ...

Makefiles: how to get a file name for a rule target from outside, in a portable way

I need to get some external data to form an output file name in a Makefile. In GNU Make I can do something like this : NAME=$(shell some_commands) $(NAME).out: file.in compile "$<" -o "$@" Some other rules have $(NAME).out as a prerequisite so I need $(NAME).out as a target. I can't use substitution+quotes here as this is not in...

Unix alias command not working as expected

i have a command to kill some processes as below: kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'` the command works perfectly fine >psu|grep MF1pp|grep -v grep|awk '{print $2}' 29390 29026 $>kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'` $>psu|grep MF1pp|grep -v grep|awk '{print $2}' when i create an alias as below a...

How to run a shell from Jsp?

Hey guys, my question is self explanatory. I want to run a shell,thats calling a procedure, from a jsp using a button. The procedure is CREATE OR REPLACE PROCEDURE DEMO_PRC (dist IN variable,mrno IN variable, yr IN variable,flags OUT number) IS begin flags:=0; // CODE THAT GENERATES A UTIL..... flags:=1; end; / And the shell is: sq...

Running the shell scripts in Background

Hello, I would to give the user the feature to run the shell script in background. My shell program instantiates a number of other shell scripts. Here is a small code snippet of my script ./main.sh # Main script in main.sh I call preprocessing.sh create_dir.sh handle_file.sh post_processing.sh report_generation.sh I would like t...

send output to file from within shell script

I'm creating a script for users to run. I need to redirect the output to a file I'm creating from inside the script (hostname-date). I have all the pieces except for how to copy the output of the script from inside the same script. All the examples I can find call the script and > it into the log, but this isn't an option. -Alex ...

Help with if statements and else (newbie)

Hi all, I am just new to programming in Unix and have a small issue that I am unsure of how to solve. The objective of this piece of my script is to offer the user various options as to the type of scan they would like to use. This scan detects duplicate files with specified variables depending on the option chosen. I am unable to get i...

Escaping 'echo' in batch files

Iditically simple I hope ... I'm trying to create a bash command file on the fly from within an W7 DOS shell: :: inside the .BAT file .. :: check we are in the right directory echo pwd > command.txt :: get the shell to echo its environment variables :: !!!! How do I get around this ... ? echo echo $PWD I thought prefixing the second ...

Bash shell function error : command not found

Hi all: I am new to bash so please bear with me if this is a dumb question : What I actually want to type in the shell is like this: javac -classpath "emarket.jar" Testclient.java -Xlint:unchecked The fact is, if I manually type the above line into bash, it executes with no error. However, if I craft a customized function in .bashr...

xargs I already have full command set

I have a file like this. rm a.txt mkdir foo cp a.doc docs I am used to xargs but following command is not doing anything. cat commands.txt | xargs -l1 ...

What is the fastest way to check whether a folder size is greater than a specific size?

What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome ...

How to match string/dir in a path using bash scripting

I'm trying to create a Makefile that uses information from the path to create a relevant rpm name. Suppose I have two different possible paths: PATH1 = /usr/local/home/jsmith/code/main PATH2 = /usr/local/home/jsmith/code/dev/ver2 If "main" is detected in the path, I want to detect and append "main" to the rpm name. If "dev" is detec...

How can I make the watch command interpret vt100 sequences?

Consider this simple example (which displays in red): echo -e "\033[31mHello World\033[0m" It displays on the terminal correctly in red. Now consider: watch echo -e "\033[31mHello World\033[0m" It does not display the color. Note: I am aware that it is easy to write a loop that mimics the basic behavior by clearing and rerunning. How...

problem with awk script

Hello, when I call my awk script, I keep getting an error : sam@sam-laptop:~/shell/td4$ awk -f agenda.awk -- -n Robert agenda.txt awk: agenda.awk:6: printf "Hello" awk: agenda.awk:6: ^ syntax error the script contains this : #!/usr/bin/awk BEGIN { } printf "Hello" END { } Thank you ...

xargs not working

I want all the lines with assert_equal and without amazon. I tried following but it is not working. ack assert_equal | xargs ack -v amazon ...

Average and maximum size of directories

I have a directory and a bunch of sub-directories like this: - directory1 (sub-dir1, sub-dir2, sub-dir3, sub-dir4, sub-dir5...........and so on, hundreds of them...) How do I find out what is average size of the sub-directories? And how do I find what is the maximum size of the sub-directories? All using Unix commands... Thanks. ...

How to write ONE line of command that scp all the sub-directories in a directory to a remote machine

something like: scp -r all_directories_in_current_directory fenix@xxxxx:~/data anyone can give me a clue? ...

Dispose of SWT shell when cursor moves out of it

Hi! I'm implementing a custom preview/tooltip for an Eclipse plug-in. It did it using a Shell in SWT, removing all its trimmings and placing a text box inside it. It looks great. However now I need to dispose of the shell when the cursor moves out of the shell window and I ran into some issues: Does it make sense to attach a mousemov...

Floating Point Comparison in Shell Script

Hello, Can you please suggest me the syntax for doing floating point comparison in shell script. I am using bash. I would ideally like to use as part of if statement here is a small code snippet : key1="12.3" result="12.2" if (( $result <= $key1 )) then # some code here fi thanks Kiran ...

Multithreading in Bash

I would to introduce multithreading feature in my shell script. I have a script which calls the function read_cfg() with different arguments. Each of these function calls are independent. Would it be possible to instantiate these function calls (not scripts) parallelly. Please let me how can we achieve that.. ? ...