Unix Shell - Newb request: scripts

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > March 2004 > Newb request: scripts





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Newb request: scripts
Ann

2004-03-23, 5:35 am

Hi. I need 3 scripts that will help me in Linux - wound anyone try to help
me? I know it's
not hard to learn bash, but i'm new and i gave up. They are simple. Maybe
there is something similar to be found on www - I've found many others, but
none of these:

1. Simple thing to move directory with subdirectories/files to new location.
Nice if it returns number of copied (moved) files and megabytes.
2. Script that lists (ls) current dir with full info (date/size) and
optionally, with arguments:
sorts (by date or size) and number of positions listed (example
my_list -s -10 that will show 10 full-info files sorted by size)
3. simple alias to replace my cd-rom folder by given name and to change
prompt to /home/user/bin/given_cd_folder_name (if possible - give the cd
name when linux starts)

Thanks Very Much, if anyone helps...
Ann


John L

2004-03-23, 6:36 am


"Ann" <procesorabc@poczta.onet.pl> wrote in message news:c3p3e2$f2n$1@news.onet.pl...
> Hi. I need 3 scripts that will help me in Linux - wound anyone try to help
> me? I know it's
> not hard to learn bash, but i'm new and i gave up. They are simple. Maybe
> there is something similar to be found on www - I've found many others, but
> none of these:
>
> 1. Simple thing to move directory with subdirectories/files to new location.
> Nice if it returns number of copied (moved) files and megabytes.


Can you not simply use the mv command?

There are other ways, if not.

Try this with test directories and files until you
understand what is going on. It is quite easy to
overwrite your most precious files if you are careless.


> 2. Script that lists (ls) current dir with full info (date/size) and
> optionally, with arguments:
> sorts (by date or size) and number of positions listed (example
> my_list -s -10 that will show 10 full-info files sorted by size)


ls. The -t argument will sort by time (date/age). -r will reverse
the order of sorting. To sort by size, you can use -S.

"man ls" for more details.

> 3. simple alias to replace my cd-rom folder by given name and to change
> prompt to /home/user/bin/given_cd_folder_name (if possible - give the cd
> name when linux starts)


I do not understand what you want.

Your prompt can be set quite easily. It is the variable PS1 (PS2,
PS3, and PS4 are sub-prompts). So PS1="What now? " will set your
prompt. Some people set their prompts to include the directory they
are in. Others use the classic "$ ". The convention is that root's
prompt is always "# ".

I think your problem is that you have frightened yourself by
trying to write shellscripts. Start with the basic commands.
Generally, these will do what you want. You can use the man
and info commands to see how they work.

Soon, you will want to combine commands, using pipes to
pass the output of one command into another. Then you will
have started writing shellscripts without noticing.

--
John.


Michael Heiming

2004-03-23, 6:36 am

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ann <procesorabc@poczta.onet.pl> wrote:
> Hi. I need 3 scripts that will help me in Linux - wound anyone try to help
> me? I know it's
> not hard to learn bash, but i'm new and i gave up. They are simple. Maybe


Why? You said it's not hard. Sounds a bit like you would be to
lazy to do any work on your side. But then, this is a newsgroup
not a corporate help-desk, where people get paid to help you.
There are lots of knowledgeable people out here willing to help
you, but you have to do your part first.

> there is something similar to be found on www - I've found many others, but
> none of these:


Sounds like homework?

> 1. Simple thing to move directory with subdirectories/files to new location.


Use 'mv' no script needed.

> Nice if it returns number of copied (moved) files and megabytes.


You would need to calculate/store them before moving, since mv
doesn't display even with -v the files moved, only directories on
my box.

> 2. Script that lists (ls) current dir with full info (date/size) and
> optionally, with arguments:


There's no script needed, just try 'man ls' for options.

> sorts (by date or size) and number of positions listed (example
> my_list -s -10 that will show 10 full-info files sorted by size)


ls -alS | head -10

Show us what you already have?

- --
Michael Heiming (GPG-Key ID: 0xEDD27B94)

Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of spam.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAYBwJAkPEju3Se5QRAn2dAJ9QvPvGsTBq
L4thcZTIEHZhAoFzGwCgsjOI
34di14V85+utgELuw6WBaYw=
=E5RP
-----END PGP SIGNATURE-----
Mark Daniels

2004-03-25, 3:35 pm

Ann,

You are much more likely to receive a response if you post the code
that you have already written. Without posting your code people are
likely to assume that this is either a homework assignment or
something else that you didn't spend any time on before asking for
help. Just a suggestion.

Mark
Walt R

2004-03-25, 6:48 pm

Michael Heiming <michael+USENET@www.heiming.de> wrote in message news:<a66p3c.p9t.ln@news.heiming.de>...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Ann <procesorabc@poczta.onet.pl> wrote:
>
> Why? You said it's not hard. Sounds a bit like you would be to
> lazy to do any work on your side. But then, this is a newsgroup
> not a corporate help-desk, where people get paid to help you.
> There are lots of knowledgeable people out here willing to help
> you, but you have to do your part first.
>
>
> Sounds like homework?
>
>
> Use 'mv' no script needed.
>
>
> You would need to calculate/store them before moving, since mv
> doesn't display even with -v the files moved, only directories on
> my box.
>
>
> There's no script needed, just try 'man ls' for options.
>
>
> ls -alS | head -10
>
> Show us what you already have?
>
> - --
> Michael Heiming (GPG-Key ID: 0xEDD27B94)
>
> Remove +SIGNS and www. if you expect an answer, sorry for
> inconvenience, but I get tons of spam.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
>
> iD8DBQFAYBwJAkPEju3Se5QRAn2dAJ9QvPvGsTBq
L4thcZTIEHZhAoFzGwCgsjOI
> 34di14V85+utgELuw6WBaYw=
> =E5RP
> -----END PGP SIGNATURE-----

**

There is a great "Advanced Bash Scripting Guide" avaliable at:

tldp.org

Walt R.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com