#!/bin/sh
#My script
echo "Are you sure you want to reorganize your files?"
echo "Type y or Y to continue. Anything else will stop the process"
read response
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
mkdir video
mkdir audio
mkdir text
mv -v *.txt text >> log.txt
mv -v *.wmv video >> log.txt
mv -v *.mov video >...
I have several files in a specific directory.
A specific string in one file can occur in another files.
If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string.
Example:
file1
ShortName "Blue Jeans"
price 89.47
cur EURO
file2
ShortName "Blue Jea...
Consider the following:
me@mine:~$ cat a.sh
#!/bin/bash
echo "Lines: " $LINES
echo "Columns: " $COLUMNS
me@mine:~$ ./a.sh
Lines:
Columns:
me@mine:~$ echo "Lines: " $LINES
Lines: 52
me@mine:~$ echo "Columns: " $COLUMNS
Columns: 157
me@mine:~$
The variables $LINES and $COLUMNS are shell variables, not environmental variables, and ...
I'm not entirely new to programming, but I'm not exactly experienced. I want to write small shell script for practice.
Here's what I have so far:
#!/bin/sh
name=$0
links=$3
owner=$4
if [ $# -ne 1 ]
then
echo "Usage: $0 <directory>"
exit 1
fi
if [ ! -e $1 ]
then
echo "$1 not found"
exit 1
elif [ -d $1 ]...
I'm building a small shell script for finding cat/man pages on a wide range of unix systems... in bash, I could build all possible paths by doing this:
# default search paths
default=$(echo /usr/{share, local, dpkg, XR11}/man/{man, cat}{1..8})
for path in $default
do
...
done
Unfortunately, I'm forced to use sh... I could build th...
Hey I would like to convert a string to a number
x="0.80"
#I would like to convert x to 0.80 to compare like such:
if[ $x -gt 0.70 ]; then
echo $x >> you_made_it.txt
fi
Right now I get the error integer expression expected because I am trying to compare a string.
thanks
...
I want to reproduce the pager behavior that git-diff uses but I don't know how. Is there a way I could find out what options it uses with less?
I already tried this: strings "$(dirname $(which git-diff))/*" | grep 'less '
And this (while less was running): ps aux | grep less <= Didn't show me which options it was using.
I'm on Darwin....
The following shell scrip will check the disk space and change the variable "diskfull" to 1 if the usage is more than 10%
The last echo always shows 0
I tried the global diskfull=1 in the if clause but it did not work.
How do I change the variable to 1 if the disk consumed is more than 10%
#!/bin/sh
diskfull=0
ALERT=10
df -HP | grep -...
Hi, Just a quick question I haven't found an answer for by searching...
How do I get the current checked out revision number from my SVN-dir?
More clearly: I don't want the latest revision number since that can be my own commit, but the revision number of the latest update I made in my local repo.
Or, if that is easier, I want to be a...
hi, yet another newbie question
i have a few makefiles that store shared variables, such as CC=gcc , how should i name them ?
candidates are
common.mk
Make.common
Makefile.common
which is more classic?
similarly, i have some shell scripts, which should i choose among the following:
do_this_please.sh
do-this-please.sh
DoThisPlease.sh
...
I'm attempting to hook into whatever explorer calls when a file is opened (double-click, context menu open, etc.), however I can't figure out which function that is.
Originally, I thought it was ShellExecute, as that does the same thing as far as I can tell, but after hooking into it I learned that it's only used when a new explorer win...
Hey,
I want to use php's exec() function on an ubuntu server.
The problem is, I alway get an error, that the command is not found. For example using
exec("echo 123");
prints
sh: /echo: not found
To me, it looks like php is using the sh shell, when I want to be using bash.
I tried changing the shell for www-data in /etc/passwd,...
Can AppleScript take the output of a shell script or variable and put it in the paste buffer?
I have a file with a password for every day (formatted "date,password") and I want to write a script that when run will look up the date and output the password for that date.
That part is not a problem, I'm just wondering if there is a way ...
Below is the snippet of code that keeps giving me the problem. Could someone explain to me why my code isn't working.
# Shell Version of Login Menu
Administrator ()
{
clear
./Administrator.sh
}
# ------ Student User Menu ------
Student_Menu()
{
clear
./studentMenu.sh
}
# ------ Borrow Menu ------
Borrow_Menu()
{
c...
I need to below permission policy to my files under www folder
664 to all files www recursively
755 to all directories under www recursively
I tried
find . -type f -exec chmod 644 {} ;
find . -type d -exec chmod 755 {} ;
But always getting error
find: missing argument to `-exec'
What is the solution?
...
OK, I'm probably not the first person to attempt to put together a PHP web-based interface to rsync to ease deployment, but there goes.
We have a 'QA' server locally and a 'Staging' server at Rackspace. I've set up SSH key pairings so I can rsync between the two servers and it all works great. The problem is that rsync is a bit flaky as...
How come FILE_FOUND is 0 at the end of this bugger :
FILE_FOUND=0
touch /tmp/$$.txt
ls -1 /tmp/$$.* 2>/dev/null | while read item; do
FILE_FOUND=1
echo "FILE_FOUND = $FILE_FOUND"
done
echo "FILE_FOUND = $FILE_FOUND"
rm -f /tmp/$$.txt 2>/dev/null
??!!
On Unix FILE_FOUND stays at 1 (as it should), but on Linux (RedHat, Cygw...
I have a script that connects to a server using ssh. While in a loop, it fails to connect to the second server after connecting to the first one. I guess I have to quit from that server to come back to the calling script. How do I quit the ssh session?
while read dbname myip
do
ssh root@$myip "mysqldump - some command " | mysql -hhost -...
Please recommend a good book to start with the shell scripting and then going ahead to have in depth and precise knowledge of shell scripting.
...
I'm peeking through some shell scripts - what's the purpose of the x in the comarison shcu as
if [ "x$USER" != "x$RUN_AS_USER" ]; then
su - $RUN_AS_USER -c "$CATALINA_HOME/bin/startup.sh"
else
$CATALINA_HOME/bin/startup.sh
fi
...