Checking the case of columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking the case of columns
# 1  
Old 05-11-2011
Checking the case of columns

Hi,

Is there a function in awk or sed which will check the case of the columns.

If my column 8 is in lower case then I want to change my column 10 data in lower case and vice versa.

I know in awk we have tolower and toupper functions but can we manipulate the data based on the case ??

Code:
Sourcedata

This is just some example data

abc|xyz|XYZ|.|.|.|.|oracle|.|ORACLE|
abc|xyz|XYZ|.|.|.|.|sqlserver|.|sqlserver|
abc|xyz|XYZ|.|.|.|.|td|.|TD|


Code:
Target data 

abc|xyz|XYZ|.|.|.|.|oracle|.|oracle|
abc|xyz|XYZ|.|.|.|.|sqlserver|.|sqlserver|
abc|xyz|XYZ|.|.|.|.|td|.|td|

--Mora
# 2  
Old 05-11-2011
Code:
tolower($8)==$8 {$10=tolower($10) }

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 05-11-2011
Code:
awk -F\| -vOFS=\| '$8~"[[:lower:]]+"{$10=tolower($10)}1' file

# 4  
Old 05-11-2011
Does this give you some ideas?

There are character classes:

[:alpha:] to check alpha characters
[:lower:] to check lowercase
[:upper:] to check uppercase

Code:
$ echo HELLO | tr -d "[:upper:]"

$ echo HELLO smart person | tr -d "[:upper:]"
 smart person

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking the CSV File Columns

Hi All, i have a CSV file like below, col1 col2 col3 col4 col5 col6 col7 a1 a2 a3 a4 a5 a6 a7 b1 b2 b3 b4 b5 b6 b7 c1 c2 c3 c4 c5 c6 c7 d1 d2 d3 d4 d5 d6 d7 Col1,col2.. are the column names and... (1 Reply)
Discussion started by: dileep_d10
1 Replies

2. Shell Programming and Scripting

Checking for ranges based on 2 columns

Hi, I have a file with 6 columns. I want to check if column 1 and 2 fall between column 5 and 6 I want to call them as "TRUE_genes" if not then call them as "FALSE_genes". I can do it for checking one column but how to mention about two columns. file1 110371373... (1 Reply)
Discussion started by: Diya123
1 Replies

3. Shell Programming and Scripting

Row to columns - special case

Hi. Let me start saying that i am kinda new to bash, and have few skills in programming. I've been advised to use bash to manipulate large .csv files. I've been able to do some data filtering using fors, grep and tail commands. That was kinda easy seeing examples. But now i need to do some hard... (1 Reply)
Discussion started by: jmarmitt
1 Replies

4. Shell Programming and Scripting

Two columns output in simple case menu?

EDIT : System used : Any Linux distribution. Hello everyone, I m having quite a headache trying to figure out why I m having a 2 columns output in the following code : #!/bin/ksh menu_rotation() { #Variables CHOIX1="Rotation 1" CHOIX2="Rotation 2" CHOIX3="Rotation 3" ... (11 Replies)
Discussion started by: Sekullos
11 Replies

5. Shell Programming and Scripting

Checking the required columns in File

Hello Experts, File contains 10 columns with | delimeter. 1,3,4,5,7,9 columns are required columns means it should contains values. i need those records, rest of it will contain or not contain data. test1.txt: a@a.com|a|b|c|d|e|f|g|h|i |a|b|c|d|e|f|g|h|i b@b.com|a||c|d|e|f|g|h|i... (7 Replies)
Discussion started by: muralikri
7 Replies

6. Shell Programming and Scripting

Checking required columns in the file

Hi, File contains with TAB delimeter file,i want check the 2,3 are not null test1@gmail.com 100 test test2@gmail.com 101 test test3@gmail.com test test4@gmail.com 102 OUTPUT test1@gmail.com 100 test test2@gmail.com 101 test Please help me with one single command in... (2 Replies)
Discussion started by: muralikri
2 Replies

7. Programming

Checking columns in SQL, comparing user input and sizes.

I'm writing a KSH shell script that's using SQL though DB2. If I have a table defined and populated db2 "create table tb(num int,letter char(4))" db2 "insert into tb values(111,a) db2 "insert into tb values(112,b) db2 "insert into tb values(111,c) How can I check if a letter user... (0 Replies)
Discussion started by: busdude
0 Replies

8. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

9. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question