Creating usernames from a list of names


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating usernames from a list of names
# 1  
Old 04-14-2011
Creating usernames from a list of names

Hello everyone,

I am trying to create a script that will make usernames (last name and first letter of name - for example, James Bond = bondj).

At this point, I figured out how to make a script that can read the list of names from a text file.

Here is what I have:

Code:
#!/bin/bash

while read user_list; do
     echo "$user_list" | tr 'A-Z' 'a-z'
done < "user_list"

The tr 'A-Z' 'a-z' minimizes the capital letters of the names to lower case so I feel I am close.

Your help would greatly be appreciated Smilie
# 2  
Old 04-14-2011
Code:
echo "James Bond" |awk '{print tolower($2 substr($1,1,1))}'

# 3  
Old 04-14-2011
Quote:
Originally Posted by rdcwayx
Code:
echo "James Bond" |awk '{print tolower($2 substr($1,1,1))}'

Can you explain what that command does? During class, we never went through awk, substr, tolower, etc.
# 4  
Old 04-14-2011
Quote:
Originally Posted by RSpades
Can you explain what that command does? During class, we never went through awk, substr, tolower, etc.
Homework?
# 5  
Old 04-15-2011
Quote:
Originally Posted by rdcwayx
Homework?
Yes, I am doing homework, but I'm not asking for an answer.

It would be cool to receive hints and tips on what I should look into.
# 6  
Old 04-15-2011
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to list the names of the files from all the subdirectories?

Hi, I'm currently trying to print the names of all the .txt files in the subdirectories that contain the string I'm searching. I tried with this code, but it seems that it searches for the names that matches the string instead of searching for the string in the individual files and printing the... (2 Replies)
Discussion started by: nuclearpenguin
2 Replies

2. Shell Programming and Scripting

List the file names that differ

Hello, I have two directories - prev and current . They both have same multiple subdirectories and files. Now the current directory can have some updated files and some new files added that is not in prev. I want to find the list of file names that differ. I am doing this because i can not... (2 Replies)
Discussion started by: jakSun8
2 Replies

3. Shell Programming and Scripting

get file names from the list

Hi Experts, Here is my scenario: Am maintaining a file which has list of logs with complete path and file names like bleow a/b/c/Daily/file1_20111012.log d/e/f/Monthly/file1_20111001.log g/h/Daily/file1_20110120.log i/Daily/file1_20110220.log How to copy the file names frm the list... (7 Replies)
Discussion started by: laxm
7 Replies

4. UNIX for Dummies Questions & Answers

Creating a column based list from a string list

I have a string containing fields separated by space Example set sr="Fred Ted Joe Peter Paul Jean Chris Tim Tex" and want to display it in a column format, for example to a maximum of a window of 100 characters And hopefully display some thing like Fred Ted Joe ... (3 Replies)
Discussion started by: kristinu
3 Replies

5. Web Development

MYSQL: Creating Dynamic Table Names 5.1

Hey everyone. Thanks for looking at this. I'm trying to create a table with the dynamic name of TableName + today's date. My variables are all happily created but the system chokes when I try to create the new table name example: Set @BFBW = CONCAT("BFBW", CURDATE()); Select @BFBW; ... (2 Replies)
Discussion started by: Astrocloud
2 Replies

6. UNIX for Dummies Questions & Answers

Creating named directories from a list of names

Hi There, I'm a competent computer user that is learning basic unix commands. This is a slightly hypothetical question (for now at least!) but I can see a need for doing something like this in the near future. So I recently learned this command mkdir foo{1..100} which of course create's... (4 Replies)
Discussion started by: lookslikejames
4 Replies

7. Shell Programming and Scripting

List of file names

I have the following list of file names stored in $fnames, so that if I do foreach f ($fnames) echo "$f" end I will get n02-z30-sr65-rgdt0p50-dc0p002-16x12drw-run1 n02-z30-sr65-rgdt0p50-dc0p002-16x12drw-run2 n02-z30-sr65-rgdt0p50-dc0p002-16x12drw-run3... (3 Replies)
Discussion started by: kristinu
3 Replies

8. Shell Programming and Scripting

Creating array containing file names

I am wondering how I can save the file names (stored in $file or $fnames) in array which I can access with an index. alias MATH 'set \!:1 = `echo "\!:3-$" | bc -l`' set narg = $#argv while ($iarg < $narg) MATH iarg = $iarg + 1 set arg = $argv set opt = ` echo $arg | awk... (1 Reply)
Discussion started by: kristinu
1 Replies

9. Shell Programming and Scripting

Compare 2 list and delete certain names

Hi, I currently have a script that takes a list of names and compares it with another list and appends non-duplicate names. I want to modify my script such that it will look at a list of names and for every name preceded by the tag "<delete>" (without the quotes) it checks the other list for... (12 Replies)
Discussion started by: eltinator
12 Replies

10. UNIX for Dummies Questions & Answers

How to Pass a list of file names to ls

Hi I have a list of file names generated from a find command. The list does not show complete file information. I would like to do this: generate the list of file names pass each file name generated to ls -l command what is the best way to do this without a script? I have tried... (2 Replies)
Discussion started by: GMMike
2 Replies
Login or Register to Ask a Question