Sponsored Content
Top Forums UNIX for Advanced & Expert Users Problem while counting number of fields in TAB delimited file Post 302530407 by vikanna on Tuesday 14th of June 2011 02:08:03 AM
Old 06-14-2011
Quote:
Originally Posted by itkamaraj
i guess, the if statement is failing..

Code:
 
if [ $delimiter_char = "TAB" ]
then
echo "Inside the TAB condition"
col_cnt=`echo $header_line | awk -F'/t' '{print NF}'`
else
echo "Coming here for TAB?"
col_cnt=`echo $header_line | awk -F"$delimiter_char" '{print NF}'`
fi

execute the script as below

Code:
./get_col_lengths.sh customer.dat 'TAB'

see, which echo is printing

change the if condition as below and execute it once again

Code:
if [ "$delimiter_char" eq "TAB" ]

No dear, "if" is working, tried that already
still i'm putting output here

./get_col_lengths.sh CUSTOMER.dat 'TAB'
No. of Records in CUSTOMER.dat : 200
No. of Columns in CUSTOMER.dat : 1
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies

2. Shell Programming and Scripting

Counting non empty fields and calculating with that number

Hello all, I have a problem with a skript of mine: My input has the following format 1,33296 transcript_id"ENSRNOT00000018629" 0 1,33296 0 0 transcript_id"ENSRNOT00000029014" 0 0,907392 transcript_id"ENSRNOT00000016905" 0,907392 0 transcript_id"ENSRNOT00000053370" 0 0... (0 Replies)
Discussion started by: DerSeb
0 Replies

3. UNIX for Advanced & Expert Users

merge two tab delimited file with exact same number of rows in unix/linux

Hi I have two tab delimited file with different number of columns but same number of rows. I need to combine these two files in such a way that row 1 in file 2 comes adjacent to row 1 in file 1. For example: The content of file1: field1 field2 field3 a1 a2 a3 b1 b2 b3... (2 Replies)
Discussion started by: mary271
2 Replies

4. UNIX for Dummies Questions & Answers

tab delimited file that is not tab delimited.

Hi Forum I have a tab delimited file that opens well in Openoffice calc (excel). But when I perform any operation in command line, it reads the file incorrectly. When I 'save As' the same file in office as tab delimited then it works fine. The file that I think is tab delimited is actually... (8 Replies)
Discussion started by: imlearning
8 Replies

5. Shell Programming and Scripting

Print records which do not have expected number of fields in a comma delimited file

Hi, I have a comma (,) delimited file, in which few fields are enclosed with in double quotes " ". I have to print the records in the file which donot have expected number of field with the line number. File1 ==== name,desgnation,doj,project #header#... (7 Replies)
Discussion started by: machomaddy
7 Replies

6. Shell Programming and Scripting

Help with converting Pipe delimited file to Tab Delimited

I have a file which was pipe delimited, I need to make it tab delimited. I tried with sed but no use cat file | sed 's/|//t/g' The above command substituted "/t" not tab in the place of pipe. Sample file: abc|123|2012-01-30|2012-04-28|xyz have to convert to: abc 123... (6 Replies)
Discussion started by: karumudi7
6 Replies

7. Shell Programming and Scripting

How to make tab delimited file to space delimited?

Hi How to make tab delimited file to space delimited? in put file: ABC kgy jkh ghj ash kjl o/p file: ABC kgy jkh ghj ash kjl Use code tags, thanks. (1 Reply)
Discussion started by: jagdishrout
1 Replies

8. UNIX for Dummies Questions & Answers

Need to convert a pipe delimited text file to tab delimited

Hi, I have a rquirement in unix as below . I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column. ex: Input Text file: 1|A|apple 2|B|bottle excel file to be generated as output as... (9 Replies)
Discussion started by: raja kakitapall
9 Replies

9. UNIX for Dummies Questions & Answers

Replace period in a tab delimited file to a number

I have a file like this. It is tab delimited. Unfortunately, the missing data was filled in with a period "." (see the leading lines 1-5 columns) I want to substitute the periods for misisng data with an integer "-999". however, I do not want the global replace to change the other periods seen... (7 Replies)
Discussion started by: genehunter
7 Replies

10. UNIX for Beginners Questions & Answers

Replace a column in tab delimited file with column in other tab delimited file,based on match

Hello Everyone.. I want to replace the retail col from FileI with cstp1 col from FileP if the strpno matches in both files FileP.txt ... (2 Replies)
Discussion started by: YogeshG
2 Replies
RCS2LOG(1)						    BSD General Commands Manual 						RCS2LOG(1)

NAME
rcs2log -- RCS to ChangeLog generator SYNOPSIS
rcs2log [-c changelog] [-h hostname] [-i indent] [-l length] [-R] [-r option] [-t tabwidth] [-u login<TAB>fullname<TAB>mailaddr] [-v] [--help] [--version] [file ...] DESCRIPTION
The rcs2log utility generates a change log prefix from RCS files (perhaps in the CVS repository) and the ChangeLog (if any). The options are as follows: -c changelog Output a change log prefix to changelog (default ChangeLog). -h hostname Use hostname in change log entries (default current host). -i indent Indent change log lines by indent spaces (default 8). -l length Try to limit log lines to length characters (default 79). -R If no file(s) are given and RCS is used, recurse through working directory. -r option Pass option to subsidiary log command. -t tabwidth Tab stops are every tabwidth characters (default 8). -u login<TAB>fullname<TAB>mailaddr Assume login has fullname and mailaddr. -v Append RCS revision to file names in log lines. --help Output help. --version Output version number. SEE ALSO
rcs(1), rcsintro(1), rlog(1), rcsfile(5) AUTHORS
Paul Eggert <eggert@twinsun.com> BUGS
Report bugs to <bug-gnu-emacs@gnu.org>. BSD
February 15, 2003 BSD
All times are GMT -4. The time now is 03:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy