Find the answer to your Linux question:
Results 1 to 2 of 2
I am new to programming and wanted to know if I could get some assistance on this shell programming problems I wrote two script files: a rename file bash script ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    4

    Lightbulb Simple file rename and deletion

    I am new to programming and wanted to know if I could get some assistance on this shell programming problems I wrote two script files: a rename file bash script file that suppose to check the input and output files and a script that deletes files that haven't been used on a directory for a long time. However, I ran into some complications in my search and compiling on the script. I have tried to get some help from other forums and of course, I'm getting the run around.

    Here are my codes:
    code 1

    #!/bin/bash

    files=$(ls -1 | grep .mp3)

    for x in $files
    do
    mv $x band_song$x
    done
    .................................................. ....................
    code 2

    #!/bin/bash
    for X in *.html
    do
    rm "$X";
    done

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by acwbrat View Post
    I am new to programming
    i recommend you readthis.
    Code:
    #!/bin/bash
    
    files=$(ls -1 | grep .mp3)
    
    for x in $files
    do
    mv $x band_song$x
    done
    ......................................................................
    use shell expansion instead of grepping...
    Code:
    for x in *mp3
    ...

    Code:
    #!/bin/bash
    for X in *.html
            do
                    rm "$X";
            done
    just do rm *html

Posting Permissions

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