Sponsored Content
Full Discussion: arguments in bash
Top Forums Shell Programming and Scripting arguments in bash Post 302582769 by elginmulizwa on Sunday 18th of December 2011 05:41:22 AM
Old 12-18-2011
Java arguments in bash

this script moves all the doc files to a specified directory....i have managed to put an argument but the problem im facing is puting the full path where the scripts are moving to for example i want to run the script like this below

./loo -d then path where im moving the files (i.e ./loo -d the second argument where files are moving to)

this is my code

Code:
#!/bin/bash
From="/home/elg19/lone/doc"
To="/home/elg19/documents"

if [ $1 = -d ]; then
cd "$From"
for i in pdf txt doc; do
  find . -type f -name "*.${i}" -exec mv "{}" "$To" \;
done
fi


Last edited by radoulov; 12-18-2011 at 07:10 AM.. Reason: Code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Shell - # of arguments

Hi!, How can I check the number of arguments passed from the shell in a bash shell ? (1 Reply)
Discussion started by: DNAx86
1 Replies

2. Shell Programming and Scripting

Make a list in bash out of arguments

Hello, I have a very stupid/simple problem, but for some reason I cannot figure out...and I need your help! I am writting a bash scrip that should be executed using "my_script X Y Z T" where X Y Z and T can be any string, but there can be any number of arguments. I want my script to do... (4 Replies)
Discussion started by: jolecanard
4 Replies

3. Shell Programming and Scripting

bash functions arguments

This script is called fuu; #!/bin/bash speak() { case $1 in 1)echo one ;; 2)echo two ;; 3)echo three ;; esac } speak exit 0 when i run fuu 2 i expect "two" like... (2 Replies)
Discussion started by: Tártaro
2 Replies

4. Homework & Coursework Questions

BASH Environment Variables as arguments?

1. The problem statement, all variables and given/known data: Write a shell program called myenv which takes one argument. The argument should be the name of an environment variable, such as PATH HOME etc. myenv should print out the value of the variable given as the argument. If no argument is... (1 Reply)
Discussion started by: Helix
1 Replies

5. Shell Programming and Scripting

Bash too many arguments error

Hello, I've got this little script that gets a bunch of comics and puts them in an html file. However, when I check that the comic URL is there and that it's a new one, I get the "too many arguments" error. The script is this: CADURL=`curl --silent http://www.cad-comic.com/cad/ | grep -o... (10 Replies)
Discussion started by: killer54291
10 Replies

6. Shell Programming and Scripting

bash read within function with arguments

I have trouble getting this logic to work #!/bin/bash function assign_var(){ while do read -p "$2 :" $3 done } assign_var '$IPADDRESS' ipaddress IPADDRESS Basicly, i want to make sure that entry is made (i can add more sophisticated checks later), but the idea is to recycle... (11 Replies)
Discussion started by: serverchief
11 Replies

7. Shell Programming and Scripting

arguments in bash

This script moves all the doc files to a specified directory. I have managed to put an argument but the problem I am facing is putting the full path where the scripts are moving to, for example I want to run the script like this below ./loo -d then path where im moving the files (i.e ./loo -d... (3 Replies)
Discussion started by: elginmulizwa
3 Replies

8. Shell Programming and Scripting

Bash script with arguments

Could someone help me with the script below? I am trying to make a script having just one arguement as a command and then it executes the appropriate code #!/bin/bash if then echo "Available commands:" echo "./exec.sh cmd1" echo "./exec.sh cmd2" elif then cmd1 =... (1 Reply)
Discussion started by: spiridakos
1 Replies

9. Shell Programming and Scripting

Passing arguments to a bash script

Hi, I wanted to pass an argument to a bash script. So that the argument is used inside the awk command inside the bash script. I know the noraml way of passing argument to a bash script as below : sh myScript.sh abc Inside the bash script i can use like this myArg1=$1 wc $myArg But... (8 Replies)
Discussion started by: shree11
8 Replies

10. Shell Programming and Scripting

[bash] cd: too many arguments

Hello everyone, Could someone please explain to me why I get cd: too many arguments when I select a dir that has one or more spaces in the name? This is the code #!/bin/bash tmp_loc=$(zenity --file-selection --directory) if ]; then exit 0 else location=${tmp_loc// /\\ } # this... (7 Replies)
Discussion started by: soichiro
7 Replies
DH_INSTALLYORICK(1)						     Debhelper						       DH_INSTALLYORICK(1)

NAME
dh_installyorick - install Yorick add-on packages SYNOPSIS
dh_installyorick [debhelper options] [-m] [--no-make-install] DESCRIPTION
dh_installyorick is a debhelper program that installs the files of your Yorick add-on at the right place when building a Debian package. For a simple plug-in package, this is mostly done by calling "make DESTDIR=debian/<package> install" and then moving arch-independent files to usr/share. Note that there is no Y_SITE/contrib directory in the Debian packages, its content is merged into YSITE/i. Calling "make ... install" can be disabled by using the "--no-make-install" flag. This is useful in particular for interpreted add-on pack- ages, which do not ship with a standard Yorick Makefile. If the "-m" flag is used (but not the "-n" one), dh_installyorick will also add lines to your package's postinst and postrm scripts to call "update-yorickdoc --auto" if the yorick-doc package is installed. It is necessary to call dh_installdeb after dh_installyorick for this to work. It is usually not necessary with a recent dpkg supporting triggers, so this possibility is kept mostly for easing backports and should be deprecated soon. dh_installyorick will look for a file named debian/<package>.ynstall for additional files to install (see YNSTALL FILE below). The prefix "<package>." can be omitted for the main binary package being built (usally the first one listed in debian/control). For the time being, Y_SITE=Y_HOME=/usr/lib/yorick. Requests to install a file under Y_SITE results in its installation under /usr/share/yorick. dh_installyorick handles the creation of the necessary symbolic links from Y_HOME to /usr/share/yorick. Files that are installed in a directory ending in "/bin" or "/sbin", as well as files that are pointed at by symbolic link in such a direc- tory, are installed with execution permission for everyone. OPTIONS
-m Modify postinst/postrm scripts to add a call to update-yorickdoc. This is needed only if the target dpkg does not support triggers. If both "-m" and "-n" are specified, the scripts are not modified. --no-make-install Do not call "make DESTDIR=debian/<package> install". --infofile= An additional pkg_mngr .info file to install. Additionally, dh_installyorick abides by the following standard debhelper options: -a/--arch, -i/--indep, --mainpackage, -n, --no-act, -N/--no-package, -p/--package, -P/--tmpdir, -s/--same-arch, and -v/--verbose. YNSTALL FILE
Blank lines are ignored, several blank character are counted as one, and line starting with "#" (possibly following one or more blanks) are ignored. Each non-comment, non-blank line should be of the form: file [directory [link]] Where file is the file to install, directory the directory it should be installed in, and link an optional symbolic link pointing on the installed file. file the relative path from the top directory of the package source to the file. If link is not specified, file can contain shell globs and actually denote sevral files. If directory is not specified, it is guessed from the extension of file: .i files are installed in Y_SITE/i, .gs and .gp in Y_SITE/g, .info in Y_SITE/packages/installed, .packinfo, .aliases and .keywords in /usr/share/yorick-doc, and .so in Y_HOME/lib. directory the full path (without leading "/") into which the file should be installed. If the file is to be installed inside Yorick's Y_SITE or Y_HOME directory (which will almost alway be the case), it is possible (and advisable) to not specify the full path, but to write "Y_SITE/" or "Y_HOME" followed by the relative path from there. It is also possible to omit this "Y_SITE/" or "Y_HOME/" prefix if directory starts whith one of: Y_SITE/i, Y_SITE/i0, Y_SITE/i-start, Y_SITE/g, Y_SITE/packages, Y_HOME/bin or Y_HOME/lib. link the full path to a symbolic link that should point to the installed file. The same shortcuts apply as for directory. EXAMPLES
The four following lines in debian/ynstall would be equivalent: somefile.i /usr/share/yorick/i somefile.i Y_SITE/i somefile.i i somefile.i Likewise, the following are equivalent: somefile.i /usr/share/yorick/i0 somefile.i Y_SITE/i0 somefile.i i0 Example with a symlink. Here, somefile.i is a script that is both useful #included from within Yorick or from the command line. Its first line reads "#!/usr/bin/yorick -batch". somefile.i i usr/bin/command_name SEE ALSO
debhelper(7), update-yorickdoc(1), deb-triggers(5) This program is a part of yorick-dev but is made to work with debhelper. Note that only compatibility level 5 has been implemented and tested. This script is not idempotent, dh_clean -k should be executed between any two runs. AUTHORS
Thibaut Paumard <paumard@users.sourceforge.net> 2008-05-15 DH_INSTALLYORICK(1)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy