Results 1 to 3 of 3

Thread: Using mv in a script

  1. #1
    Join Date
    Apr 2009
    Location
    Toronto, Canada
    Beans
    93
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Using mv in a script

    Hello I'm trying to write a bash script but I'm not having too much success.
    Here is the code for the script I named tr:
    Code:
    #!/bin/bash
    path=$1
    path=${path//' '/'\ '}
    echo $path
    sudo mv $path ~/.local/share/Trash/files
    Here is the command I used to execute the script:
    tr es\ se
    Here is the output:
    es\ se
    mv: cannot evaluate `es\\': No file or folder of this type
    mv: cannot evaluate `se': No file or folder of this type
    Please note that if I remove the 3rd line from the code, the output is as follows:
    es\ se
    mv: cannot evaluate `es': No file or folder of this type
    mv: cannot evaluate `se': No file or folder of this type
    The first line of the output is exactly right; however when I give this to the mv command it doesn't use it properly. I am sure this file exists in the current directory.
    Thank for the help.

    EDIT: I just realized I stuck this in a very random place. If anyone could delete this, it would be greatly appreciated.
    Last edited by silentrebel; April 15th, 2009 at 04:53 PM. Reason: I realized I'm a fool
    L'idée de communauté consiste d'offrande constante sans s'attendre à quoi que ce soit d'elle.
    The idea of community consists of constant giving without expectation of return.

  2. #2
    Join Date
    Mar 2006
    Location
    Williams Lake
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Using mv in a script

    I moved the post to a place where more people can see your question. In the future just report the post using the icon on the lower left below your username.

    Jim

  3. #3
    Join Date
    Jan 2008
    Location
    /us/al/home/mb_webguy
    Beans
    2,340
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Using mv in a script

    I'm assuming you're trying to accommodate files and directories with spaces in the name. Why can't you just do the following?
    Code:
    #! /bin/sh
    sudo mv "$@" ~/.local/share/Trash/files

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •