The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help with a 'while read' loop to change the names of files starsky Shell Programming and Scripting 6 03-01-2008 01:47 PM
How to get files names passed to a script unishiva Shell Programming and Scripting 5 11-08-2007 04:01 AM
new to writing script files bebop1111116 UNIX for Dummies Questions & Answers 0 09-17-2006 04:08 PM
Writing a shell script to untar files nkem22 Shell Programming and Scripting 4 08-22-2005 08:00 PM
Script for writing to files with sed Trufla Shell Programming and Scripting 3 04-14-2005 10:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-26-2005
technett technett is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 1
help writing script to read files names

Hi there,
I am trying to do somehting similar, but on a wider scale.
I am trying to write a script that would open the home directory, open the first (of 650) user's folder
open the ?mail directory, which every user has

Then I need the script to read each of the files and folder names with one preceding directory and a carriage return as the delimiter.
Then the output is to be put into a file called .mailboxlist


cd /home
cd user1
cd mail
grep ls (this is where I am most stuck – adding the ‘mail/’ before each name and a carriage return as the delimiter) > .mailboxlist (??)
cp .mailboxlist /home/user1/.mailboxlist


The file “.mailboxlist” should look like this:
mail/Sent
mail/Trash
mail/Drafts
mail/tech support
mail/test1


After that is completed, I need the script to go to the next folder (user2) and do it again.

Any help would be greatly appreciated.
Thanks,
Nett
  #2 (permalink)  
Old 04-26-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Are you looking for a snapshot of each of directory's under mail for all user's ?
  #3 (permalink)  
Old 04-26-2005
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,126
Quote:
grep ls (this is where I am most stuck – adding the ‘mail/’ before each name and a carriage return as the delimiter) > .mailboxlist (??)
Unix uses a newline as a line terminator, not a carriage return. This tend to happen automatically. You need to do stuff to suppress it, not get it.

ls | sed 's=^=mail/=' > .mailboxlist

will do what I think you want. If you need something else, tell us what os and shell you are using.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0