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,
2. I wanted 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,
3. I 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 Solution: Creating a file to test: # cat > testfile.txt
Converting upper to lower: # cat testfile.txt | tr -s '[:upper:]' '[:lower:]' > lowerfile.txt
Adding * to the front and ,*,* to the end and create test.. out file # while read line
last_file_number=`ls -1 test*.out | sort | tail -1 | cut
-c 5`
exit 0
Note: Prepending an * to a file name is a rather silly thing to do, particularly in Unix.
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|