09-23-2008
doing rot13 on a field with a random number with awk
i have a several million line file like this:
M:charity[cross]general:water:fairbanks:charity[cross]general
field 2 and field 5 are the same
i want to read the file and rot13 or any caesar cipher field 2 and replace the [ ] with a random number 1 - 9
anyone know how to do this?
something slightly more sophisticated than a caesar cipher/rotate that is reversible and could be done with awk would be great too
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello!
I wish to extract the pid where CPU is above 10%
last pid: 22621; load averages: 4.71, 5.04, 5.13 15:08:34
221 processes: 212 sleeping, 2 running, 1 stopped, 6 on cpu
CPU states: %... (3 Replies)
Discussion started by: Lomic
3 Replies
2. Shell Programming and Scripting
Hi,
I have a various files;each filled with hundreds of line with similar number of fields.
I would like to extract out field $5 from each of this file and aggregate them before printing out to a file.
I tried to :-
#!/usr/bin/awk -f
file="file1.txt file2.txt file3.txt file4.txt"
... (1 Reply)
Discussion started by: ahjiefreak
1 Replies
3. Shell Programming and Scripting
I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want.
The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies
4. Shell Programming and Scripting
Hello there.
I want some help with awk
I have this script that reads a file from awk and you can insert from keyboard any list from the fields that exist so to be printed on monitor
echo "give a choice"
read -a ans
array=${ans}
awk -F: -v k="$array" '{
... (4 Replies)
Discussion started by: covis
4 Replies
5. Shell Programming and Scripting
Hi,
I have a file that has data in it that says
00:01:48.233 1212
00:01:56.233 345
00:09:01.221 5678
00:12:23.321 93444
The file has more line than this but i just wanted to put in a snippet to ask how I would get the highest number with time stamp into another file. So from the above... (2 Replies)
Discussion started by: pat4519
2 Replies
6. Shell Programming and Scripting
Hi,
I'm trying to compare the value in a field to the value in a variable using awk. This works:
awk '$7 == "101"'but this is what I want (and it doesn't work):
value=101
awk '$7 == "$value"'
Any help or insight on this would be great. Thanks in advance. (1 Reply)
Discussion started by: goodbenito
1 Replies
7. Shell Programming and Scripting
With this script i want to print the output to a specific field-number . Can anybody help?
awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv
4 135
5 185
6 85
11 30input_6.csv
1 90
3 58
4 135
7 60
8 55
10... (1 Reply)
Discussion started by: sdf
1 Replies
8. Programming
How can I choose randomly the row numbers of my file in awk? (4 Replies)
Discussion started by: Homa
4 Replies
9. Shell Programming and Scripting
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies
10. Shell Programming and Scripting
What is an awk command to print only fields with a number in it??
Input file.......
S,S,S,S,S,S,S,S,S
001S,S,S,S,S,S,S,S,S
00219S,23S,24S,43S,47S,S,S,S,S
00319S,10S,23S,41S,43S,47S,S,S,S
00423S,41S,43S,46S,47S,S,S,S,S
00510S,23S,24S,43S,46S,S,S,S,S
00610S,23S,43S,46S,47S,S,S,S,S... (2 Replies)
Discussion started by: garethsays
2 Replies
LEARN ABOUT FREEBSD
unstr
STRFILE(8) BSD System Manager's Manual STRFILE(8)
NAME
strfile, unstr -- create a random access file for storing strings
SYNOPSIS
strfile [-Ciorsx] [-c char] source_file [output_file]
unstr source_file
DESCRIPTION
The strfile utility reads a file containing groups of lines separated by a line containing a single percent '%' sign and creates a data file
which contains a header structure and a table of file offsets for each group of lines. This allows random access of the strings.
The output file, if not specified on the command line, is named source_file.dat.
The options are as follows:
-C Flag the file as containing comments. This option cases the STR_COMMENTS bit in the header str_flags field to be set. Comments are
designated by two delimiter characters at the beginning of the line, though strfile does not give any special treatment to comment
lines.
-c char Change the delimiting character from the percent sign to char.
-i Ignore case when ordering the strings.
-o Order the strings in alphabetical order. The offset table will be sorted in the alphabetical order of the groups of lines refer-
enced. Any initial non-alphanumeric characters are ignored. This option causes the STR_ORDERED bit in the header str_flags field
to be set.
-r Randomize access to the strings. Entries in the offset table will be randomly ordered. This option causes the STR_RANDOM bit in
the header str_flags field to be set.
-s Run silently; do not give a summary message when finished.
-x Note that each alphabetic character in the groups of lines is rotated 13 positions in a simple caesar cypher. This option causes
the STR_ROTATED bit in the header str_flags field to be set.
The format of the header is:
#define VERSION 1
uint32_t str_version; /* version number */
uint32_t str_numstr; /* # of strings in the file */
uint32_t str_longlen; /* length of longest string */
uint32_t str_shortlen; /* length of shortest string */
#define STR_RANDOM 0x1 /* randomized pointers */
#define STR_ORDERED 0x2 /* ordered pointers */
#define STR_ROTATED 0x4 /* rot-13'd text */
#define STR_COMMENTS 0x8 /* embedded comments */
uint32_t str_flags; /* bit field for flags */
char str_delim; /* delimiting character */
All fields are written in network byte order.
The purpose of unstr is to undo the work of strfile. It prints out the strings contained in the file source_file in the order that they are
listed in the header file source_file.dat to standard output. It is possible to create sorted versions of input files by using -o when
strfile is run and then using unstr to dump them out in the table order.
FILES
strfile.dat default output file.
SEE ALSO
byteorder(3), fortune(6)
HISTORY
The strfile utility first appeared in 4.4BSD.
BSD
February 17, 2005 BSD