Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

parsing a line in a bash script

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

parsing a line in a bash script

Old 02-13-03, 06:50 PM
  #1  
Mod Emeritus
Thread Starter
 
Join Date: Feb 1999
Location: Gone to the islands - 'til we meet again.
Posts: 19,053
Likes: 0
Received 0 Likes on 0 Posts
parsing a line in a bash script

I'm trying to come up with a good way to take a standard company file and automatically put it in the form of passwd. To do this I need to be able to take a file of columns like this...

Emp# LName, FName MI Emailaddress deptcode status

and make it look like

email:emp#::GID:Name:/home/email:/bin/bash

where email is their email username.

I thought that I could use cut to get the fields, but not all of the records have a MI and some have a MI and another name. So, cutting by field doesn't work. I also tried cutting by character, but that seems to treat multiple spaces used to create the columns as one... so, the start point of Emailaddress isn't consistant.

Any ideas on how to attack this?
Old 02-14-03, 08:41 AM
  #2  
Mod Emeritus
Thread Starter
 
Join Date: Feb 1999
Location: Gone to the islands - 'til we meet again.
Posts: 19,053
Likes: 0
Received 0 Likes on 0 Posts
Wow, I expected at least someone to have an idea for this!

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 On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.