Find the answer to your Linux question:
Results 1 to 5 of 5
Hi All, whilst now studying bash scripting, I'm wondering what people mainly use it for. I know that probably each person''s reuirements are different, how about showing us newbs, not ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2004
    Location
    Tokyo
    Posts
    24

    When do you use scripting:::examples.


    Hi All,

    whilst now studying bash scripting, I'm wondering what people mainly use it for. I know that probably each person''s reuirements are different, how about showing us newbs, not only to bash scripting, but newbs to Lnux too, like me, what you mainly use it for. Not asking for code examples, just where you use scripts regularly.

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    While I don't do much bash scripting, I do write Perl scripts for some stuff I do.

    For example, I recently had a clock sync error where the access times for my kernel sources were all screwy. So I wrote a Perl script to traverse all those directories and run the "touch" command on every file.

    <3 Perl.

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by Cabhan
    While I don't do much bash scripting, I do write Perl scripts for some stuff I do.

    For example, I recently had a clock sync error where the access times for my kernel sources were all screwy. So I wrote a Perl script to traverse all those directories and run the "touch" command on every file.

    <3 Perl.
    You really should learn to love find.
    Code:
    find /usr/src -print | xargs touch
    Perl's great, but it's overkill sometimes.

  4. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Yeah, I really should learn shell commands, as they make things easier. I dunno, I kinda like knowing exactly what's going on by writing my own stuff.

    As another simple thing, when I was testing out some Package Unmasking in Gentoo, I copied a file from here, but it had ~amd64 in it, and I needed ~x86. So I wrote a little Perl script to go through and replace it.

    I'm sure there's a much easier Bash way to do it, but I love writing scripts .

  5. #5
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by Cabhan
    I'm sure there's a much easier Bash way to do it, but I love writing scripts .
    So do I, so I understand your feelings. However, using the right command is part of the fun, especially when you're pushed for time and your boss must have the results yesterday. And you get extra kudos for doing in a single command what your colleagues take 15 minutes to achieve.

    My finest moment (well, one of them!) came when I was asked to add a bit of extra functionality to a 200 line awk script. Rather than spend a day trying to understand the script, I went back to first principles and asked what they wanted to achieve and what they were starting from. I replaced the awk script with a single sed command - needless to say they were impressed with how much faster my "script" ran!:

Posting Permissions

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