Find the answer to your Linux question:
Results 1 to 7 of 7
Ho hum... well here I go. I have perfectly working desktop running Anti-christ OS. I need to keep it that way. I have just spent the day tidying up, and ...
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    46

    need some CLI help?

    Ho hum... well here I go. I have perfectly working desktop running Anti-christ OS. I need to keep it that way. I have just spent the day tidying up, and have found 20Gb of space....nice-.; I now have a 120Gb Hdd approx 1/2 used, and the rest is free space, currently all is NTFS one partition.
    Lying about useless is a 300Gb Hdd containing an old WinXP installation and a lot of "files", mainly music, film, docs etc. The old XP install, even if it could be revived, is of little or no interest to me, I have now replaced all of the programmes I need, and have a newer, working XP desktop OS etc. I would like to delete everything from the 300Gb disk EXCEPT for the files, and I suspect that linux would be a better start point. Has or could anyone come up with "catch-all" description of "files" (this from a windostel POV), and so write a command which could "delete everything except files of type a.*, b.*, c.*, d.*, etc.
    What I would like to do is to delete all but the "files" from the 300Gb, Zip them up, and copy them to the free space on the 120GB. Then I would like to reformat the 300Gb, and clone the contents of the 120Gb onto it, so that the 300 would then become my Main/Windy drive and I could use the 120 as my experimental linux drive until I was sure/confident nough to cross the Rubicon.
    Whilst tidying, I found myself in a situation which said to me " I NEED a CLI to do this", ie delete all files meeting certain criteria from an entire HDD. Doing this via (MS) GUI took hours, and I am sure that with a couple of lines, even dear old DOS could have done it, and am even surer that a Linux/Unix guru could have done the trick in seconds.

    If you have got this far, thank-you, if you reply; well hey, I am trying to emigrate to linux-land, and need a guide.... So thank-you X10 (or X11.conf if you prefer)

  2. #2
    Just Joined!
    Join Date
    Nov 2007
    Posts
    46

    bumpety bump...

    slightly disappointed that 30 folk have read, and none replied...

  3. #3
    Linux User dxqcanada's Avatar
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    259
    So what you want is a script that:

    finds all the files that you want to keep on Drive B
    add them to a zip file on Drive A
    then you can just format Drive B



    Men occasionally stumble over the truth,
    but most of them pick themselves up
    and hurry off as if nothing had happened.

    Winston Churchill


    ... then the Unix-Gods created "man" ...

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    am even surer that a Linux/Unix guru could have done the trick in seconds
    Flattery will get you nowhere.

    Most of us around here are busy writing our own scripts, or doing similar work. The way linuxforums works (as well as most other sites like this, I imagine) is on the basis of leverage: a few minutes helping you with a specific script you're working on goes a long way.

    So dig in! Do this at the command line:
    Code:
    man find
    and scroogle this:
    Code:
    bash tutorial
    Write yourself a script. At first, don't let it actually delete any files; just let it announce the names of files it would delete. (You don't want an undebugged script running haywire, do you?)

    If it doesn't work as expected, post the script here, along with its exact misbehavior and I'm sure several of us would be more than interested in helping.

    You'll have fun, I'm sure!
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    Quote Originally Posted by wje_lf View Post
    Flattery will get you nowhere.

    Most of us around here are busy writing our own scripts, or doing similar work. The way linuxforums works (as well as most other sites like this, I imagine) is on the basis of leverage: a few minutes helping you with a specific script you're working on goes a long way.

    So dig in! Do this at the command line:
    Code:
    man find
    and scroogle this:
    Code:
    bash tutorial
    Write yourself a script. At first, don't let it actually delete any files; just let it announce the names of files it would delete. (You don't want an undebugged script running haywire, do you?)

    If it doesn't work as expected, post the script here, along with its exact misbehavior and I'm sure several of us would be more than interested in helping.

    You'll have fun, I'm sure!
    very wise indeed
    Linux and me it's a love story

  6. #6
    Just Joined!
    Join Date
    Nov 2007
    Posts
    46
    Thanks for the replies folks. Firrst let me day that I had originally posted this in the "Coffee Lounge" hoping that some fellow noobs might offer guidance, at a simple level...
    Either:
    a) a kindly mod or Admin moved the post to here
    or
    b) I was drunk and posted here meself without thinking.
    Seeing my post here was a bit of a surprise, and it looks like I am a lazy slob, hoping for someone else to do some work for me, this was not my intention.
    I followed some of the links to the "scripting basics" (scroogle) pages. I am sure that in the future these will be an invaluable resource, but as things are atm they are a bit advanced for me, although they say "no prior knowledge of scripting needed" they DO assume familiarity with commands and pipes, and I don't really know any of this yet. I am guessing that an .sh script is roughly equiv. to a DOS batch file?
    For the task in hand I don't even think that a script will be needed. I just have to do some work on learning how to use pipes, I guess something like FIND all files except *.x, *.y *.z | rm *.* and learn the switches to do this inside sub directories. One thing I am still confused about is that linux does not have file-type suffixes, and my files, of course do. Does this mean I should somehow make the full-stop explicit,?

    Anyway, I am just musing out loud here, and thanks again for your replies

  7. #7
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I am guessing that an .sh script is roughly equiv. to a DOS batch file?
    Your guess is correct.
    linux does not have file-type suffixes, and my files, of course do. Does this mean I should somehow make the full-stop explicit,?
    Linux doesn't require that you use file-type suffixes, but you can use them if you want. They have no special meaning for Linux. Some applications running under Linux may use the suffixes. And you should know that if you ever see the word "extension", that means "file-type suffix".

    And there's nothing particularly special about the full stop. It's a character in the filename, just like "a" or "b". So you should make them as explicit in your searches as you would a letter or a numerical digit.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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