help writing a unix script..new to writing scripts i have a file with names in it lets call it a testfile.txt...
1. i want to make sure all the names are lowercase...so i was going to do this..
tr '[A-Z]' '[a-z]' testfile.txt > lowerfile.txt2. i wante to add a *, to the front of each name and a ,*,* to the end of each name and i was able to do this by this line command..
cat lowerfile.txt | xargs -iz eacho "*," "Z" ",*,*" > newfile.out3. wanted to name newfile.out to test(next number available).out...like test1.out..test2.out what ever the next available number is ...and echo the output file is ......out
Creating a file to test:
# cat > testfile.txt
Name1
NaME2
NamE3
nAmE4Converting upper to lower:
# cat testfile.txt | tr -s '[:upper:]' '[:lower:]' > lowerfile.txtAdding * to the front and ,*,* to the end and create test.. out file
# while read line
do
echo "* $line ,*,*" >> newfile.out
done < lowerfile.txtlast_file_number=`ls -1 test*.out | sort | tail -1 | cut -c 5`
next_file_number=` expr $last_file_number + 1 `
mv newfile.out test${next_file_number}.outexit 0
Hope it helped.
I believe that nobody offered a solution to this problem because prepending an * to a file name is a rather silly thing to do, particularly in Unix.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |