09-03-2007
I tried the following code in aix,in ksh
code is long but there is no while etc.
let say your original file origfile
step 1.
sed s/"|"/" "/g origfile >tempfile
/** if you dont have sed ,you must change "|" with blank with someting */
/after this your original file looks like this 12123 12345678 */
grep -n "^$" tempfile >origfile,rm tempfile
/*after this your original file looks like this ;
1 12123 12345678
2 42142 53988989
step 2.
/**produce 1 million random numbers and save to the RandNumbersFile**/
step 3.
/**produce 1 million random numbers and save to the RandRecordsFile**/
sort -u RandRecordsFile>tempfile
mv tempfile RandRecordsFile
/*you can produce 1 million numbers but if you sort it unically it can be less than 1 million. you must be sure that every line in this file is unique, the above command arranges this*/
let "NeededLine=1000000-`wc -l RandRecordsFile |awk '{print $1}'`"
/*this line shows you how many new records do you need after sort */
counter=0
while [ $counter -lt $NeededLine ]
do
/**produce random RandomRecord(means random number).I mean you must add your code here **/
grep $RandomRecord RandomRecordsFile >/dev/null
if [ $? -ne 0 ]
then
echo $RandomRecord >>RandomRecordsFile
let "counter=$counter+1"
fi
done
sort -u RandomRecordsFile>tempfile
paste tempfile RandNumbersFile >RandomRecordsFile
rm tempfile
/** after this your RandomRecordsFile looks like this ;
1 12345678
27 53988989
first one stands for record num and the second rundom field (orig second field) **/
join -v1 origfile RandomRecordsFile >tempfile /** unmatched lines **/
join -o 1.1,1.2,2.2 origfile RandomRecordsFile >>tempfile /*matched lines */
sort -u tempfile >origfile /*sort on field1 */
/**if you need add these lines
cut -f2,f3 origfile >tempfile
sed s/" "/"|"/g tempfile>origfile **/
rm tempfile
so the code is;
/**produce 1 million random numbers and save to the RandNumbersFile**/
/**produce 1 million random numbers and save to the RandRecordsFile**/
cp yourfile origfile
sed s/"|"/" "/g origfile >tempfile
grep -n "^$" tempfile >origfile
sort -u RandRecordsFile>tempfile
mv tempfile RandRecordsFile
let "NeededLine=1000000-`wc -l RandRecordsFile |awk '{print $1}'`"
while [ $counter -lt $NeededLine ]
do
/**produce random RandomRecord(means random number).I mean you must add your code here **/
grep $RandomRecord RandomRecordsFile >/dev/null
if [ $? -ne 0 ]
then
echo $RandomRecord >>RandomRecordsFile
let "counter=$counter+1"
fi
done
sort -u RandomRecordsFile>tempfile
paste tempfile RandNumbersFile >RandomRecordsFile
join -v1 origfile RandomRecordsFile >tempfile
join -o 1.1,1.2,2.2 origfile RandomRecordsFile
sort -u tempfile >origfile
rm tempfile
Last edited by fazliturk; 09-03-2007 at 09:41 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How to edit large file using vi where you can't increase /usr/var/tmp anymore? (3 Replies)
Discussion started by: nazri
3 Replies
2. Shell Programming and Scripting
I am trying to edit a file that has 33k+ records. In this file I need to edit each record that has a 'Y' in the 107th position and change the 10 fields before the 'Y' to blanks. Not all records have a 'Y' in the 107th field.
ex:
... (8 Replies)
Discussion started by: jxh461
8 Replies
3. Shell Programming and Scripting
hi All,
Plz let me know how to edit a file with 2000000 records.
each record contains with 40 field seperated by |.
i want modify 455487 record, but i am uable to edit this large file using vi editor in unix.
plz let me know how to modify this file.
Thanks in advance.
-Bali Reddy (3 Replies)
Discussion started by: balireddy_77
3 Replies
4. Shell Programming and Scripting
Hi,
I need to make a script to edit a file. File is a large file in below format
Version: 2008120101
;$INCLUDE ./abc/xyz/Delhi
;$INCLUDE ./abc/xyz/London
$INCLUDE ./abc/xyz/New York
First line in the file is version number which is in year,month,date and serial number format. Each... (5 Replies)
Discussion started by: makkar4u
5 Replies
5. Shell Programming and Scripting
Hello,
I am attempting to create a command that I can eventually put into a loop so I can edit 1file on many servers. I would like to edit the file in place with sed -i. If not I will take any suggestions on how to use a temp file. I need to remove a email address from the configuration file... (4 Replies)
Discussion started by: abacus
4 Replies
6. Solaris
Dear Gurus,
I need you to advice or suggestion about the best solution to copy data around 200-300G from serverA(location A) to serverB(location B). Normally, I will share folder and then copy but it takes too long time(about 2 days).
Do you have any suggestion or which way should be... (9 Replies)
Discussion started by: unitipon
9 Replies
7. Shell Programming and Scripting
Hello, I am using tcsh on AIX.
I would like to write a script that does the following:
1. given an inode, how do I find exactly the name of the file?
I know I could do this using ls -i | grep <inode>
but it returns: <inode> <filename>. I need some string manipulation or something to... (1 Reply)
Discussion started by: lastZenMaster
1 Replies
8. Shell Programming and Scripting
Hi,
I lack the utter fundamentals on how to craft an awk script.
I have hundreds of text files that were mangled by .doc format so all the lines are broken up so I need to join all of the lines of text into a single line. Normally I use vim command "ggVGJ" to join all lines but with so many... (3 Replies)
Discussion started by: n00ti
3 Replies
9. Shell Programming and Scripting
Whenever I am trying to edit a file in unix with vi editor, I am getting the following error:
<data>
:Tmp file too large
Is there any way that I can edit the file other than vi. Any help is really appreciated.
Thanks (10 Replies)
Discussion started by: bobby1015
10 Replies
10. Shell Programming and Scripting
Hi All,
Daily I am getting the updated file.
I have to search for this file in all directories and sub directories.
If the file existed in a particular directory then move this updated file to that particular directory.
If the file is not existed in any of the directories then place this... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies
PWGEN(1) General Commands Manual PWGEN(1)
NAME
pwgen - generate pronounceable passwords
SYNOPSIS
pwgen [ OPTION ] [ pw_length ] [ num_pw ]
DESCRIPTION
The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. Human-memo-
rable passwords are never going to be as secure as completely completely random passwords. In particular, passwords generated by pwgen
without the -s option should not be used in places where the password could be attacked via an off-line brute-force attack. On the other
hand, completely randomly generated passwords have a tendency to be written down, and are subject to being compromised in that fashion.
The pwgen program is designed to be used both interactively, and in shell scripts. Hence, its default behavior differs depending on
whether the standard output is a tty device or a pipe to another program. Used interactively, pwgen will display a screenful of passwords,
allowing the user to pick a single password, and then quickly erase the screen. This prevents someone from being able to "shoulder surf"
the user's chosen password.
When standard output (stdout) is not a tty, pwgen will only generate one password, as this tends to be much more convenient for shell
scripts, and in order to be compatible with previous versions of this program.
In addition, for backwards compatibility reasons, when stdout is not a tty and secure password generation mode has not been requested,
pwgen will generate less secure passwords, as if the -0A options had been passed to it on the command line. This can be overriden using
the -nc options. In the future, the behavior when stdout is a tty may change, so shell scripts using pwgen should explicitly specify the
-nc or -0A options. The latter is not recommended for security reasons, since such passwords are far too easy to guess.
OPTIONS
-0, --no-numerals
Don't include numbers in the generated passwords.
-1 Print the generated passwords one per line.
-A, --no-capitalize
Don't bother to include any capital letters in the generated passwords.
-a, --alt-phonics
This option doesn't do anything special; it is present only for backwards compatibility.
-B, --ambiguous
Don't use characters that could be confused by the user when printed, such as 'l' and '1', or '0' or 'O'. This reduces the number
of possible passwords significantly, and as such reduces the quality of the passwords. It may be useful for users who have bad
vision, but in general use of this option is not recommended.
-c, --capitalize
Include at least one capital letter in the password. This is the default if the standard output is a tty device.
-C Print the generated passwords in columns. This is the default if the standard output is a tty device.
-N, --num-passwords=num
Generate num passwords. This defaults to a screenful if passwords are printed by columns, and one password.
-n, --numerals
Include at least one number in the password. This is the default if the standard output is a tty device.
-H, --sha1=/path/to/file[#seed]
Will use the sha1's hash of given file and the optional seed to create password. It will allow you to compute the same password
later, if you remember the file, seed, and pwgen's options used. ie: pwgen -H ~/your_favorite.mp3#your@email.com gives a list of
possibles passwords for your pop3 account, and you can ask this list again and again.
WARNING: The passwords generated using this option are not very random. If you use this option, make sure the attacker can not
obtain a copy of the file. Also, note that the name of the file may be easily available from the ~/.history or ~/.bash_history
file.
-h, --help
Print a help message.
-s, --secure
Generate completely random, hard-to-memorize passwords. These should only be used for machine passwords, since otherwise it's
almost guaranteed that users will simply write the password on a piece of paper taped to the monitor...
-v, --no-vowels
Generate random passwords that do not contain vowels or numbers that might be mistaken for vowels. It provides less secure pass-
words to allow system administrators to not have to worry with random passwords accidentally contain offensive substrings.
-y, --symbols
Include at least one special character in the password.
AUTHOR
This version of pwgen was written by Theodore Ts'o <tytso@alum.mit.edu>. It is modelled after a program originally written by Brandon S.
Allbery, and then later extensively modified by Olaf Titz, Jim Lynch, and others. It was rewritten from scratch by Theodore Ts'o because
the original program was somewhat of a hack, and thus hard to maintain, and because the licensing status of the program was unclear.
SEE ALSO
passwd(1)
pwgen version 2.05 January 2006 PWGEN(1)