0
votes
1answer
23 views

How to use the awk to print the output

This command nstats gives me output like below. How can I use awk or grep to give me the uptime with only days on it? I cannot use the "" to get the output. HOSTNAME LOAD MEMORY SWAP PROCS ...
0
votes
3answers
39 views

How to find length of string in shell

i need to calculate it using pure sh shell only. What happening is /bin/sh is actually a soft link to bash or other shell.Hence ${#STRING} gives length of string as it is advance bash feature. Can ...
0
votes
1answer
45 views

Monitor process start time, end time using shell script

I am working on project in which we execute shell script which invokes the Node process and further processing happens. I want to design a script which should log the start time, termination time of ...
0
votes
1answer
39 views

Memory usage of a process in a shell script

I want to find out the memory usage of a process in a shell script.I tried to use this piece of code : while[process] do if [ -e /proc/$pidno/statm ]; then m=`awk '{OFS="\t";print ...
0
votes
0answers
22 views

how to detect availability of GUI

For Linux: I have a text mode installation (bash) script and a graphical mode setup program (a Free Pascal binary). I'd like to run the graphical setup when a GUI is available. How do I detect which ...
-2
votes
1answer
65 views

how to run command in another terminal in Linux script

In Linux shell script I have to run few commands under another user but I am enable to. Please advice some suggestions. $ jumpto -T -u ... after this command it enters in another terminal and I ...
1
vote
1answer
68 views

Batch convert txt file encoding

I have about 700 files that were the results of a closed caption software process. I can open the files on my PC or Mac in a GUI, but when I open it on the server with nano, I get this: ...
0
votes
1answer
125 views

Execute the shell command in subshell or in background?

Actually I mainly work with Ruby, but now I have created a bash script file. From this script file I am displaying the messages on the screen. Here is my scenario. I have used aosd_cat module for ...
0
votes
1answer
85 views

How do I call function after prompt for input in a Linux shell script?

The title says it all. After Im prompted, I want yes and no to respectively call a function. # Check to see if you ran this script before echo echo I need to know if this is your first time... while ...
0
votes
1answer
147 views

Shell script to check all the URLs from a file or list

I'm looking for a shell script to check a list of URLs and give output. For example: http://abc.com/index.php http://abc1.com/index.php I may place them in a separate file or inside the script. I ...
-1
votes
1answer
52 views

Copy one directory to another while retaining its structure

Let's assume I have the following source directory: source/ subdir1/file1 subdir1/file2 subdir2/file3 subdir3/file4 And target directory: target subdir1/file5 subdir2/file6 ...
-1
votes
1answer
2k views

Shell files (*.sh) to batch file (*.bat) converter?

It's quiet tedious to convert shell scripts into batch files. Is there a way to automatically and easily perform .sh to .bat conversion or vice versa?
0
votes
1answer
33 views

alias can't find a file that actually exists

On my personnal computer, not a server, in my .bash_profile (I'm on OSX) — sym-linked to .bashrc, I have the following line among some others : alias deploy=sh ~/dir/ectory/deploy.sh The file ...
1
vote
1answer
46 views

How do I identify shell script execution vs dot execution

I'm writing a bash script that needs to run on the current process for it to be useful. That is, I want to make sure that the script was invoked with source script.sh or . ./script.sh and not ...
0
votes
0answers
15 views

(MAC) Change location of shell script's shell

When I make an executable shell script ("http://chimpy.wordpress.com/2010/08/29/mac-os-x-shortcut-link-to-python-script/", but without the python part), It's pointer location (The location commands ...
0
votes
2answers
233 views

curl shell command always returns error status 0 - even when fails on input errors

Example: trying to upload a non existing file - curl -d @no-real-file http://google.com | echo $? - returns 0. How can I make curl fail on input errors?
0
votes
2answers
50 views

I want to find out word which ends with ()…Use grep

I want to find out word which ends with ()...Using the grep command in linux. grep file_name_where_i_want_to_search "*()" some thing like that....but its not working
0
votes
1answer
63 views

Bash single quotes in find command

I'm having some troubles getting a shell script to work. I'm trying to dynamically generate the find command based on user input and I'm running into the problem that my variables in the find command ...
2
votes
4answers
158 views

Add a display to let user wait in bash

I am looking for a pretty stupid piece of code for bash that will show a kind of "please wait" rolling display, with the characters : - \ | / The first problem is that I don't know the name of this ...
0
votes
5answers
1k views

How to test if a variable is equal to a number in shell

I have this shell script that isn't working. Input: Server_Name=1 if [ $Server_Name=1 ]; then echo Server Name is 1 else echo Server Name is not 1 fi Output: Server Name is 1 But, if i ...
1
vote
2answers
299 views

Filling up the hard drive until certain amount of space is left?

I'm doing some testing of a product on Apple and Android devices. I'd like a script that will fill up the devices hard drive until 100KB space is left on the drive it's runs against to. Also in linux ...
1
vote
1answer
412 views

Use “>>” Redirection Operator for Non-Existent File In tcsh/csh

I'm writing tcsh scripts and I would like to append to a log file, but if the log file doesn't exist before appending to it, I get an error (reproduced below). In bash the file gets created if it ...
1
vote
1answer
311 views

In a Shell scripts, check version of installed package, make a decision based on output

Looking to write a cross distro / cross version shell script that makes sure a forced version of PHP is installed Example: Ubuntu 12.04 has 5.3, Ubuntu 13.10 has 5.5, Debian 7 has 5.4 I need this ...
0
votes
2answers
94 views

Instructions embedded in Bash script?

Is there a way to make a bash script require a set of parameters when it's loaded, and if not, it will automatically spit out an echo to the screen giving instructions? Looking at this example of a ...
3
votes
2answers
316 views

Xterm control sequence to get RGB value for ANSI color

The meat In (some) terminals you can use a sequence like this; printf "\e]4;3;rgb:cc/78/33\e\\" to set the third color in the ANSI color palette to the RGB values represented by #CC7833. Can you ...
2
votes
3answers
182 views

Utility to non-destructively fold or re-indent HTML

I have a script that takes input from wget or similar and searches through it for key words using grep. (I promise i am not trying to parse HTML with regular expressions, it is just a convenient way ...
0
votes
2answers
60 views

How to Sum Date (in minutes) Shell

I need some help here, I'm not a expert with shell scripting but I am trying to do a script where I need to take the Epoch number followed by the date, but for with the all hours of the day with a ...
7
votes
1answer
2k views

Shell script to find all types of files in a directory with their count

I want to write a shell script or alias to find the number of different types of files in a directory. For example, sample output of script should be: *.h 20 *.c 40 *.cpp 10 Makefile 3
2
votes
1answer
141 views

What this command :(){ :|: & };: does? [duplicate]

What does this shell command do in Linux :(){ :|: & };: How can it be used in Denial of Service attacks?
1
vote
1answer
251 views

run a shell script on terminal if terminal is idle for few minutes in linux

i can get terminal idle time by w command as follows $ w 14:37:58 up 2 days, 20:16, 2 users, load average: 0.12, 0.16, 0.14 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ...
2
votes
2answers
91 views

UNIX-Shell Scripting

While executing the below script, I'm getting an error: Syntax error at line 1 : `(' is not expected. sudo su - user1 -c "cd $HOME ; tar -cvf $HOME/mine.tar `cat /tmp/$LOGNAME/List` " where List ...
1
vote
2answers
220 views

How to merge ls commands colors with the output of find or du?

I have a simple alias to list the size of files&folders in cwd. ( including dotfiles in this case , ignoring zero sizes ) du -sh .[!.]* * | sort -hr | grep -v '^0' which can be achieved ...
0
votes
1answer
44 views

Queue commands to last subshel even if one of them launches new shell

I want to automate something writing simple script launching consecutively few scripts one after another. And then setting some aliases at the top shell. Problem: few of these commands launch new ...
0
votes
1answer
204 views

Can you switch into Single User Mode Without Rebooting?

Is it possible to switch into single user mode WITHOUT rebooting and holding CMD+S. For example, can I write a shell script to switch into single user mode? If so, for which operating systems?
0
votes
0answers
22 views

Loop through folder with higher space usage in shell? [duplicate]

I would like to create an script where give me a report of which folders have the higher usage space and keep doing that until there's no folder anymore. Today I do this manually, with: sudo du -h ...
1
vote
4answers
435 views

parse log file with heavy output

I'd like to monitor my vsftpd logs and pull information from the logs to process the files that have been uploaded. Up till now everything was great and worked fine: tail -n0 -F /var/log/vsftpd.log | ...
0
votes
1answer
159 views

parse vsftpd log with shell script

I try to parse this line with vsftpd: Sun Apr 7 07:23:33 2013 [pid 23590] [cam02430] OK UPLOAD: Client "206.132.183.209", "/20130407/07/20130407_072324D.avi", 496846 bytes, 383.38Kbyte/sec with: ...
2
votes
2answers
80 views

multiple conditionals in shell script

This is driving me insane. There are many posts on this but nothing is working for me. I want to check if a file is not an avi or mpg then I want to exit. Here is a simple example: #!/bin/sh ...
0
votes
1answer
135 views

how to compare negative floating points in bash

We tested our script and it fails on negative floating points comparison in bash. What are we doing wrong ? $F1=10000000000 $F2=300 FLP=$(bc <<< "scale=5; ($F2 - $F1)/$F2 * 100") if [ $FLP ...
-2
votes
1answer
2k views

Calculate % difference and file sizes between two files

We have two zip files and would like to compare them. We're also interested in calculating the percentage difference between them and the file size. Is there a tool that can do this quickly?
1
vote
1answer
473 views

Shell Script : How use find expression in a for?

I would like to use the find command in a for. So I did this: for logs in `find $BACKUP_FOLDER -exec ls -la {} \; | awk '{ if ( $8==2011) printf $0"\n" }'`; do // some command here done; But it ...
0
votes
2answers
82 views

Equivalents for .bat files for starting a jar file

Which are the .bat file alternatives for Linux, MacOSX and other operating systems for starting a jar file for example or another program (.exe, .app ...) with a click on this .bat / ... file? I just ...
2
votes
1answer
2k views

Shell Script to GZIP files without overwrite .gz files

I'm trying to create a shell script which receive as first parameter of a path to a folder which I would like to compress all files using gzip without overwrite the .gz files that already exist in ...
1
vote
1answer
298 views

Applescript to shell script watch folder

I am trying to setup a watch folder so that when a file is added to a folder, I can run a shell script...for this purpose I made a simple test but cannot make it work... Here is my applescript on ...
1
vote
0answers
164 views

shell script ffmpeg stops after 2 jobs [closed]

I have a pretty simple shell script and after doing the first two jobs, it just stops and sits there, doesnt do anything, it doesnt seem to matter what the third job is, if I switch the order etc, it ...
0
votes
1answer
22 views

Cannot start a script

#!/bin/bash value=$(<man.txt) echo "$value" if [ "$value" == "true" ]; then echo "startedif_manthan" ps -ef|grep sym |awk '{ print $2 }'|sudo xargs kill -9; sleep 30; sudo sh ...
0
votes
0answers
25 views

Different behavior from ubuntu server and ubuntu client on windows

#!/bin/bash # Reading cat /home/radiare/Desktop/first.txt | while read LINE do echo $LINE if [ "$LINE" == "false" ]; then echo "Inside first loop" break fi done echo "second file read started" cat ...
1
vote
2answers
298 views

Can not stat over a file name having space in it

I m very new to shell scripting and writing a script for a project. I am having a problem while doing "stat" on a file name, to check size, which has spaces in it. The problem is that I can not write ...
0
votes
1answer
279 views

Combining multiple data files with header while also adding a data column

I have multiple tab delimited data files that are separated by month in the format jan06.txt, feb06.txt, ..., dec07.txt. Within each file, it looks something like: Header1 Header2 Header3 ... Data1 ...
2
votes
1answer
82 views

How to list all scripts called by a master script?

I want to list all scripts (recursively) which are being called by a master script. For example: master.sh a.sh >> this script calls a1.sh, a2.sh, a3.sh etc b.sh >> this one calls b1.sh, ...