LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   touch and input options (https://www.linuxquestions.org/questions/linux-software-2/touch-and-input-options-425349/)

ejkeebler 03-16-2006 07:36 AM

touch and input options
 
Basically i have a list of about 150 words, I would like to create an empty file for each word, since this is beginning to appear to be a real pain in windows, so hopefully someone can give me an idea for linux. the file that i have can be in .xls, .csv, .txt, pretty much any format if that helps at all. example file is just a list of names like jim bob, sue may, bobby joe. I would like to use it as input for touch and create empty files jimbob.txt, suemay.txt, bobbyjoe.txt or similiar.

Thanks!

zeitounator 03-16-2006 08:32 AM

Assuming:
- you have all your names in a txt file (called bla.txt in the example)
- all names are separated by commas and contain no other "special character" than white space
the following simple script seams a reasonable start point
Code:

#!/bin/bash

# Set Input Field Separator to 'comma'
IFS=","

# loop on each field found
for name in `cat ./bla.txt`
do
  # strip out white spaces
  filename=`echo $name | sed 's/ //g'`
  # create the file
  touch $filename.txt
done

adapt and enhance to suit your needs.

Good luck :)


All times are GMT -5. The time now is 02:03 AM.