06-09-2006
Sorting Files
How to sort such files which contains records of varying length and varying lines? (With respect to Bash shell)
Eg:
Each record begins with a sting of 1/0(binary) which may or may not be followed by properties like AB,BS etc.
I have to sort such records on the basis of 1/0 string and keep the properties associated with that record intact.
Following lines are contained in the file
10101010101111101
AS sasa
BS kkk
1110000101010110
BS jsa
0110000101010100
1010000101010110
AS asas
BS sasa
CS asa
P.S: 1. A new record starts wherever a new line is starting with 1/0
2. Anyline starting with space is properties associated with the last
1/0 record
3. The number of records depicted in above file is 4
Please help in this regard.
Last edited by sandeep_hi; 06-09-2006 at 06:10 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
ok so I'm having major issues trying to figure this out:
I have this program that I'm inputting the files in hte current directory which are image files...it spits out 5 line chunks describing the files...
filename: (name of file)
size: (100 x 200)
arbitrary data
arbitrary data
arbitrary... (4 Replies)
Discussion started by: Infraredskies
4 Replies
2. Shell Programming and Scripting
Hi,
What is the command for sorting files according to their size
Thanx in advance (4 Replies)
Discussion started by: sendhil
4 Replies
3. Shell Programming and Scripting
I am currently attempting to create a file which I access from an oracle form.
At the minute I do a host command and run an ls -l e.g.
/bin/ls -l /dir/dir/dir/ > /tmp/list.txt
I then read this file within my oracle form. However I want the user to be able to restrict, sort and filter the... (2 Replies)
Discussion started by: dave_angel
2 Replies
4. UNIX for Dummies Questions & Answers
I am new to shell scripting
can u guys please provide a small script for the following senario
step1:need to find some files in a directory for ex having 020908
step2:sort them and redirecting to new file
(ex:sort abc > abc.sort)
i am trying this but giveing flag error
ls -l... (4 Replies)
Discussion started by: cgreddy2020
4 Replies
5. Shell Programming and Scripting
hi
i have file like below:
col1,col2,col3,col4
val1,val2,val3,val4
abc1,abc2,abc3,abc4
this is a 4 column file with 3 rows.
i want to sort the file like.. first on col1, then on col2 and so ..on..
i want the sort order to be descending.
Pls help..
Thnks
Sumit (2 Replies)
Discussion started by: sumit207
2 Replies
6. UNIX for Dummies Questions & Answers
hi everybody, first time writing.
Here's my question:
I've got several files in different directories like this:
aa/t1
aa/bb/t2
aa/t2
aa/bb/cc/t1
aa/t3
and would like to get this sorting:
aa/t1
aa/bb/cc/t1
aa/t2
aa/bb/t2
aa/t3 (1 Reply)
Discussion started by: Camisa
1 Replies
7. UNIX for Dummies Questions & Answers
find / -type f 2> /dev/null | find -inum +1 2> /dev/null | find -mtime -30 2> /dev/null
what i am trying to do i search all regular files in root directory with one or more
inodes modified within last 30 days.
the /dev/null is to suppress the permission denied outputs.
i am now trying to... (5 Replies)
Discussion started by: iluvsushi
5 Replies
8. Shell Programming and Scripting
i have file a
123
234
456
567
678
and file b
123|xxx|hhh|ppp or zzz
234|rrr|ttt|xxx
432|ttt|mmm|nnn
678|cft|byt|mop
i want to compare file a to file b such that when each of the lines in file a can be found in file b column1 and also xxx or hhh or ppp or zzz can be... (12 Replies)
Discussion started by: blackzinga80
12 Replies
9. Shell Programming and Scripting
I have the following set of files and I want to order them according to the ascending values of the run:
For example, doing
ls -lrt *drw*.log
gives
n02-z30-sr65-rgdt0p25-dc0p08-4x3drw.log
n02-z30-sr65-rgdt0p25-dc0p03-8x6drw.log
n02-z30-sr65-rgdt0p25-dc0p01-8x6drw.log
... (18 Replies)
Discussion started by: kristinu
18 Replies
10. Shell Programming and Scripting
Dear all,
I have a complex data file shown below,,,,,
A_ABCD_13208 0 0 4.16735 141044 902449 1293900 168919
C_ABCD_13208 0 0 4.16735 141044 902449 1293900 168919
A_ABCDEF715 52410.9 18598.2 10611 10754.7 122535 252426 36631.4
C_DBCDI_1353 0... (19 Replies)
Discussion started by: AAWT
19 Replies
HWDB(7) hwdb HWDB(7)
NAME
hwdb - Hardware Database
DESCRIPTION
The hardware database is a key-value store for associating modalias-like keys to udev-property-like values. It is used primarily by udev to
add the relevant properties to matching devices, but it can also be queried directly.
HARDWARE DATABASE FILES
The hwdb files are read from the files located in the system hwdb directory /lib/udev/hwdb.d and the local administration directory
/etc/udev/hwdb.d. All hwdb files are collectively sorted and processed in lexical order, regardless of the directories in which they live.
However, files with identical filenames replace each other. Files in /etc have the highest priority and take precedence over files with the
same name in /lib. This can be used to override a system-supplied hwdb file with a local file if needed; a symlink in /etc with the same
name as a hwdb file in /lib, pointing to /dev/null, disables that hwdb file entirely. hwdb files must have the extension .hwdb; other
extensions are ignored.
Each hwdb file contains data records consisting of matches and associated key-value pairs. Every record in the hwdb starts with one or more
match strings, specifying a shell glob to compare the lookup string against. Multiple match lines are specified in consecutive lines. Every
match line is compared individually, and they are combined by OR. Every match line must start at the first character of the line.
The match lines are followed by one or more key-value pair lines, which are recognized by a leading space character. The key name and value
are separated by "=". An empty line signifies the end of a record. Lines beginning with "#" are ignored.
In case multiple records match a given lookup string, the key-value pairs from all records are combined. If a key is specified multiple
times, the value from the record with the highest priority is used (each key can have only a single value). The priority is higher when the
record is in a file that sorts later lexicographically, and in case of records in the same file, later records have higher priority.
The content of all hwdb files is read by systemd-hwdb(8) and compiled to a binary database located at /etc/udev/hwdb.bin, or alternatively
/lib/udev/hwdb.bin if you want ship the compiled database in an immutable image. During runtime, only the binary database is used.
EXAMPLES
Example 1. General syntax of hwdb files
# /lib/udev/hwdb.d/example.hwdb
# Comments can be placed before any records. This is a good spot
# to describe what that file is used for, what kind of properties
# it defines, and the ordering convention.
# A record with three matches and one property
mouse:*:name:*Trackball*:
mouse:*:name:*trackball*:
mouse:*:name:*TrackBall*:
ID_INPUT_TRACKBALL=1
# A record with a single match and five properties
mouse:usb:v046dp4041:name:Logitech MX Master:
MOUSE_DPI=1000@166
MOUSE_WHEEL_CLICK_ANGLE=15
MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL=26
MOUSE_WHEEL_CLICK_COUNT=24
MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL=14
Example 2. Overriding of properties
# /lib/udev/hwdb.d/60-keyboard.hwdb
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*
KEYBOARD_KEY_a1=help
KEYBOARD_KEY_a2=setup
KEYBOARD_KEY_a3=battery
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn123*
KEYBOARD_KEY_a2=wlan
# /etc/udev/hwdb.d/70-keyboard.hwdb
# disable wlan key on all at keyboards
evdev:atkbd:*
KEYBOARD_KEY_a2=reserved
If the hwdb consists of those two files, a keyboard with the lookup string "evdev:atkbd:dmi:bvnAcer:bdXXXXX:bd08/05/2010:svnAcer:pn123"
will match all three records, and end up with the following properties:
KEYBOARD_KEY_a1=help
KEYBOARD_KEY_a2=reserved
KEYBOARD_KEY_a3=battery
SEE ALSO
systemd-hwdb(8)
systemd 237 HWDB(7)