Sponsored Content
Top Forums Shell Programming and Scripting Get column number with the same character length Post 302963172 by SkySmart on Thursday 24th of December 2015 06:43:43 PM
Old 12-24-2015
sorry, i didn't post the log output because the log really does not matter as i intend to use it on log of any format.

code that does something close to what i need (i added NF to also show me the number of columns of each line):

Code:
logfile=$1

tail -3000 $logfile | while read line
do
        ColumnCharCount=$(for eachwordorwhatever in $(echo $line)
        do
                  charcount=$(echo $eachwordorwhatever | awk '{print length,NF}')
                  echo ${eachwordorwhatever}=${charcount}
        done)
        echo ${ColumnCharCount}
done

sample log:

Code:
Dec=3 21=2 11:13:59=8 jserver-VirtualBox=17 kernel:=7 1=1 VbglR0HGCMInternalCall:=23 vbglR0HGCMInternalDoCall=24 failed.=7 rc=-2=5
Dec=3 21=2 11:13:59=8 jserver-VirtualBox=17 kernel:=7 1=1 VBOXGUEST_IOCTL_HGCM_CALL:=26 64=2 Failed.=7 rc=-2.=6
Dec=3 21=2 12:09:28=8 jserver-VirtualBox=17 kernel:=7 1=1 VbglR0HGCMInternalCall:=23 vbglR0HGCMInternalDoCall=24 failed.=7 rc=-2=5
Dec=3 21=2 12:09:28=8 jserver-VirtualBox=17 kernel:=7 1=1 VBOXGUEST_IOCTL_HGCM_CALL:=26 64=2 Failed.=7 rc=-2.=6
Dec=3 21=2 12:39:44=8 jserver-VirtualBox=17 kernel:=7 1=1 8=1 VbglR0HGCMInternalCall:=23 vbglR0HGCMInternalDoCall=24 failed.=7 rc=-2=5
Dec=3 21=2 12:39:44=8 jserver-VirtualBox=17 kernel:=7 1=1 8=1 VBOXGUEST_IOCTL_HGCM_CALL:=26 64=2 Failed.=7 rc=-2.=6
Dec=3 21=2 14:22:27=8 jserver-VirtualBox=17 kernel:=7 1=1 VbglR0HGCMInternalCall:=23 vbglR0HGCMInternalDoCall=24 failed.=7 rc=-2=5
Dec=3 21=2 14:22:27=8 jserver-VirtualBox=17 kernel:=7 1=1 8=1 VBOXGUEST_IOCTL_HGCM_CALL:=26 64=2 Failed.=7 rc=-2.=6
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Initializing=12 cgroup=6 subsys=6 cpuset=6
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Initializing=12 cgroup=6 subsys=6 cpu=3
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Initializing=12 cgroup=6 subsys=6 cpuacct=7
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Linux=5 version=7 4.2.0-19-generic=16 (buildd@lgw01-31)=17 (gcc=4 version=7 5.2.1=5 20151010=8 (Ubuntu=7 5.2.1-22ubuntu2)=16 )=1 #23-Ubuntu=10 SMP=3 Wed=3 Nov=3 11=2 11:38:40=8 UTC=3 2015=4 (Ubuntu=7 4.2.0-19.23-generic=19 4.2.6)=6
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 KERNEL=6 supported=9 cpus:=5
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Intel=5 GenuineIntel=12
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 AMD=3 AuthenticAMD=12
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 NSC=3 Geode=5 by=2 NSC=3
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Cyrix=5 CyrixInstead=12
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Centaur=7 CentaurHauls=12
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Transmeta=9 GenuineTMx86=12
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 Transmeta=9 TransmetaCPU=12
Dec=3 22=2 10:00:46=8 jserver-VirtualBox=17 kernel:=7 [=1 0.000000]=9 UMC=3 UMC=3 UMC=3 UMC=3

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Awk script to check length of a character

Hi All , I am trying to build a script using awk that checks columns of the înput file and displays message if the column length exceeds 35 char. i have tried the below code but it does not work properly (2 Replies)
Discussion started by: amit1_x
2 Replies

2. Shell Programming and Scripting

print a file with one column having fixed character length

Hi guys, I have tried to find a solution for this problem but couln't. If anyone of you have an Idea do help me. INPUT_FILE with three columns shown to be separated by - sign A5BNK723NVI - 1 - 294 A7QZM0VIT - 251 - 537 A7NU3411V - 245 - 527 I want an output file in which First column... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

3. Shell Programming and Scripting

How can use the perl or other command line to calculate the length of the character?

For example, if I have the file whose content are: >HWI-EAS382_30FC7AAXX:7:1:927:1368 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >HWI-EAS382_30FC7AAXX:7:1:924:1373 ACGAACTTTAAAGCACCTCTTGGCTCGTATGCCGTC I want my output calculate the total length of nucleotide. So my output should look like this:... (1 Reply)
Discussion started by: patrick chia
1 Replies

4. Shell Programming and Scripting

Parsing 286 length Character string

Hi Friends, I have .txt file which has 13000 records. Each record is 278 character long. I am using below code to extract the string and it takes almost 10 minutes. Any suggestion please. cat filename.txt|while read line do f1=`echo $line|awk '{print substr($1,1,9)}'` f2=`echo... (6 Replies)
Discussion started by: ppat7046
6 Replies

5. Shell Programming and Scripting

Add character based on record length

All, I can't seem to find exactly what I'm looking for, and haven't had any luck patching things together. I need to look through a file, and if the record length is not 874, then add 'E' in position 778. Your help is greatly appreciated. (4 Replies)
Discussion started by: CutNPaste
4 Replies

6. Shell Programming and Scripting

Need to extract data from Column having variable length column

Hi , I need to extract data from below mentioned data, having no delimiter and havin no fixed column length. For example: Member nbr Ref no date 10000 1000 10202012 200000 2000 11202012 Output: to update DB with memeber nbr on basis of ref no. ... (6 Replies)
Discussion started by: ns64110
6 Replies

7. Shell Programming and Scripting

awk command to find total number of Special character in a column

How to find total number of special character in a column? I am using awk -f "," '$col_number "*$" {print $col_number}' file.csv|wc -l but its not giving correct output. It's giving output as 1 even though i give no special character? Please use code tags next time for your code and... (4 Replies)
Discussion started by: AjitKumar
4 Replies

8. Shell Programming and Scripting

Delimit file based on character length using awk

Hi, I need help with one problem, I came across recently. I have one input file which I need to delimit based on character length. $ cat Input.txt 12345sda231453 asd760kjol62569 sdasw4g76gdf57 And, There is one comma separated file which mentions "start of the field" and "length... (6 Replies)
Discussion started by: Prathmesh
6 Replies

9. UNIX for Dummies Questions & Answers

Select lines based on character length

Hi, I've got a file like this: 22 22:35645163:T:<CN0>:0 0 35645163 T <CN0> 22 rs140738445:20902439:TTTTTTTG:T 0 20902439 T TTTTTTTG 22 rs149602065:40537763:TTTTTTG:T 0 40537763 T TTTTTTG 22 rs71670155:50538408:TTTTTTG:T 0 50538408 T TTTTTTG... (3 Replies)
Discussion started by: zajtat
3 Replies

10. Shell Programming and Scripting

Add string based on character length

Good day, I am a newbie here and thanks for accepting me I have a task to modify input data where my input data looks like 123|34567|CHINE 1|23|INDIA 34512|21|USA 104|901|INDIASee that my input has two columns with different character length but max length is 5 and minimum length is 0 which... (1 Reply)
Discussion started by: fastlearner
1 Replies
jserver(1M)                                               System Administration Commands                                               jserver(1M)

NAME
jserver - Wnn6 Kana-Kanji conversion server SYNOPSIS
/usr/lib/locale/ja/wnn/jserver [-f file] [-s file] [-h file] [-A file] [-N no] [-pno port_no] [-ds default_wnnds_list] [ + ds] DESCRIPTION
jserver provides one or more users with Kana-Kanji conversion features for Japanese input. It is launched normally from /etc/rc2.d/S94Wnn6 upon the system startup. jserver reads and processes the initialization file /etc/lib/locale/ja/wnn/ja/jserverrc when launched. OPTIONS
The following options are available. -f file Reads as the initialization file instead of the default initialization file /etc/lib/locale/ja/wnn/ja/jserverrc. -s file Stores log in file. When "-" is specified for file, the output is directed to the standard output. -h file Reads as the part of speech data file instead of the default part of speech data file /usr/lib/locale/ja/wnn/ja/hinsi.data. -A file Reads as the access control file instead of the default access conntrol file /etc/lib/locale/ja/wnn/wnnhosts. -N no Uses the value obtained by adding no to the well-known port number(22273), as TCP port number. -pno port_no Uses port_no as TCP port number instead of the well-known port number. -ds default_wnndSpecifies the list of the default dictionary lookup servers. One of the following formats is used for dictionary lookup server. hostname Specifies the dictionary lookup server that uses the well-known port number(26208) on host hostname. hostname:Specifies the dictionary lookup server that uses the well-known port number + no as port number on host hostname. hostname/Specifies the dictionary lookup server that uses port_no as port number on host hostname . Up to three dictionary lookup server can be specified by separating them with a ",". Example: hostname1,hostname2:10,hostname/26228 When this option is used, jserver tries to search and connect to the dictionary lookup server in the order specified on the startup. The dictionary lookup server first connected is used as default server. If this option is omitted and the default dictionary lookup server is defined in the initialization file jserverrc, the default server is tried. If either this option is not specified or the default dictionary lookup server is not defined in the initialization file, jserver does not connect to the dictionary lookup server by default but uses relevant dictionary files directly. FILES
/tmp/jd_sockV6 UNIX domain socket /etc/lib/locale/ja/wnnja/jserverrc jserver initialization file /etc/lib/locale/ja/wnn/wnnhosts Wnn6 access control file /usr/lib/locale/ja/wnn/ja/hinsi.data Wnn6 part of speech data file /usr/lib/locale/ja/wnn/ja/dic/iwanami/* Wnn6 system dictionary ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWjwnsu | +-----------------------------+-----------------------------+ SEE ALSO
wnnstat(1), wnnaccess(1M), wnnds(1M), wnnkill(1M), jserverrc(4), wnnhosts(4) SunOS 5.10 10 Jan 2003 jserver(1M)
All times are GMT -4. The time now is 03:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy