Identify high values "˙" in a text file using Unix command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Identify high values "˙" in a text file using Unix command
# 1  
Old 03-14-2011
Identify high values "˙" in a text file using Unix command

I have high values (such as ˙˙˙˙) in a text file contained in an Unix AIX server. I need to identify all the records
which are having these high values and also get the position/column number in the record structure if possible. Is there
any Unix command by which this can be done to :

1. Get the number of occurrences of high values in the file
2. Get the position/column of it in the record structure (optional)

I tried the option of echo "˙" but it is not able to detect them. The ascii equivalent for "˙" is 255 and I have tried
searching for the option of trying to grep using the ascii value but got no results.

Please let me know if there is any way to achieve this?

Thanks!
# 2  
Old 03-14-2011
Code:
 
can you try something like this:
 
cat > input_file
abcZ]fdsGGG
 
printf `cat input_file ` | od -An -to1
141 142 143 132 135 146 144 163 107 107 107
 
Now , based on ascii value , you have to search for the special character and then you can get that position as well.

# 3  
Old 03-14-2011
reply

Hi Panyam,

We have huge files to work upon and looking for a faster and better way other than converting each character to its ascii value.Also, the record layout changes when we try your command which would give incorrect position. To mention all the files will consist of fixed length records

Is there a way where we can run grep using the ascii value of this special character directly? Is there any better way to do this?We will just need to locate this special character and find the number of occurrences,number of records its impacting and the fields impacted based on the position.Any help on this is highly appreciated.

Thanks for replying.

Last edited by devina; 03-14-2011 at 09:37 AM..
# 4  
Old 03-14-2011
What Operating System and version are you running?
What Shell do you use?
Do you have a high-level language such as Oracle available or are you trying to do this with Shell tools and unix commands.

How big are the files?
How long is each record?

Ir you looking for characters 128-255 inclusive, or just character 255, or something else?

What are you going to do with the results? Are you going to try to change characters?
# 5  
Old 03-14-2011
Methyl,
Below are the answers.
What Operating System and version are you running?AIX 5.3
What Shell do you use?Korn Shell
Do you have a high-level language such as Oracle available or are you trying to do this with Shell tools and unix commands.-Oracle not readily available..trying with shell and unix commands
How big are the files?-Files fall in the range of 20MB-10GB
How long is each record?Record length fall in the range of 1-1000 and some even above.
Ir you looking for characters 128-255 inclusive, or just character 255, or something else?Just the 255 character i.e. small y with diaeresis as mentioned earlier.

What are you going to do with the results? Are you going to try to change characters? I will not be changing/replacing this character.I just to have the total number of occurrences in the file,number of records having this characters,number of occurrences per record and position of the character to identify which field is impacted.These results are need for analysis.
# 6  
Old 03-14-2011
something to start with - assuming your LOCALE is set correctly:
Code:
nawk 'BEGIN{y=sprintf("%c", 0255)}$0 ~ y{n+=gsub(y,"");r++}END{printf("totatlRecords->%d totalChars->%d\n",r,n)}' myFile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

How to identify varying unique fields values from a text file in UNIX?

Hi, I have a huge unsorted text file. We wanted to identify the unique field values in a line and consider those fields as a primary key for a table in upstream system. Basically, the process or script should fetch the values from each line that are unique compared to the rest of the lines in... (13 Replies)
Discussion started by: manikandan23
13 Replies

3. Shell Programming and Scripting

Please identify "unexpected end of file" bug

This is a script I got off the web for transferring Safari's "reading list" to the Pocket app. I ran it in terminal with the command bash exportsafarireadinglist.sh and got syntax error: unexpected end of file. Thanks for any help! The code: #!/bin/bash # Script to export Safari's reading... (2 Replies)
Discussion started by: kdog126
2 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Red Hat

Using "ps" command to find high processes

Sometimes idle process(%98) and load average(98.32) are very high. When its happen I check with "top" command and I kill visible process. After killing machine status already same. How can I check high process using ps command. I want to find that which processes are using more than %50 CPU or... (5 Replies)
Discussion started by: getrue
5 Replies

6. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

7. Shell Programming and Scripting

identify files with "Normal termination" and compress them into a .tar.gz file

Hi, I have hundreds of files "*.out" located in one folder, and I want to: 1. Identify the good files containing "Normal termination" (grep "Normal termination" *.out ) 2. Compress the good files into a tar.gz file (tar cvfz good.tar.gz *.goog.out ) Is there a way I can automate this... (4 Replies)
Discussion started by: rockytodd
4 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. HP-UX

Need to identify the process/app which is triggering the error "vmunix: file: table is full"

Hi, I'm seeing the error vmunix: file: table is full in syslog.log. Although changing the value of the kernel parameter nfile would make this error go away, how would I identify which process/application in the server is triggering this error? The server is a HP-UX B.11.11. Thanks in advance! (1 Reply)
Discussion started by: enchogas
1 Replies

10. UNIX for Dummies Questions & Answers

Unix "at" / "Cron" Command New Problem...Need help

Hi All, I am trying to schedule a one time job using the at command with the help of shell script for my project. The shell script should take a parameter as a command line argument from the at command itself. Is it possible to take a command line parameter for a shell script in the command... (3 Replies)
Discussion started by: Mohanraj
3 Replies
Login or Register to Ask a Question