Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, i am new and idk if i am right category... well, i want help in shell scripting in Fedora14 I want a script "Find in curent folder for files, ...
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    1

    Fedora Shell Scripting

    Hello, i am new and idk if i am right category...

    well, i want help in shell scripting in Fedora14

    I want a script
    "Find in curent folder for files, and it copy first file he find with name gived by user, if name already exist then echo error message and finish"

    command usage " bash scriptname copyASname"

    smthing like
    Code:
    #!/bin/bash
    for files in /home/user/*
    do
      if [ -f $files ] 
        then
           echo "Start copying..."
           cp $file $1
      fi
    done
    this is very simple script and dont work, $1 means SaveName $File means First file he find.
    soz for my bad english ... :/

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    Sorry, I don't understand your requirement. For example If you have 3 files in /home/user named as "a.txt b.txt and c.txt" and want to save as "alpha.txt"

    For your script will do this -
    first cp a.txt alpha.txt
    then
    cp b.txt alpha.txt
    finally
    cp c.txt alpha.txt
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

Posting Permissions

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