Sponsored Content
Top Forums Shell Programming and Scripting Checking number of commas in each line. Post 302789771 by Anupam_Halder on Thursday 4th of April 2013 08:04:19 AM
Old 04-04-2013
Checking number of commas in each line.

Hi All,

I am checking whether each line is having "n" number of commas or nor. In case not then I need to exit the process.

I tried

Code:
cat "$TEMP_FILE" | while read LINE
do 
	processing_line=`expr $processing_line + 1`
	no_of_delimiters=`echo "$LINE" | awk -F ',' '{ print NF }'`
	if [ $no_of_delimiters -ne $no_of_expected_fields ]
                echo "Error at line $processing_line"
		exit
	fi
done

It's working fine. However the number of records in the file is around .5 million. So it's taking too much time to process it. Anyway I can improve the performance?

Thanks in advanced.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sequence number checking

Hi there, I'm wanting to produce a shell script that will check through some file names and identify a skip in sequence (four digit seq num in file name). I have played on the idea of havng a file that has a sorted list of file names which I can read line at a time and cut out the sequence... (1 Reply)
Discussion started by: nhatch
1 Replies

2. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies

3. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies

4. Shell Programming and Scripting

how to get the data from line number 1 to line number 100 of a file

Hi Everybody, I am trying to write a script that will get some perticuler data from a file and redirect to a file. My Question is, I have a Very huge file,In that file I have my required data is started from 25th line and it will ends in 100th line. I know the line numbers, I need to get all... (9 Replies)
Discussion started by: Anji
9 Replies

5. UNIX for Dummies Questions & Answers

Inserting commas and replacing backslashes with commas

Hi, Newbie here. I have a file that consists of data that I want to convert to a csv file. For example: Jul 20 2008 1111 / visit home / BlackBerry8830/4.2.2 Profile/MIDP-2.0 Configuration/CLOC-1.1 VendorID/105 Jul 21 2008 22222 / add friend / BlackBerry8830/4.2.2 Profile/MIDP-2.0... (3 Replies)
Discussion started by: kangaroo
3 Replies

6. Shell Programming and Scripting

Counting number of commas(,) in a variable

Hi all, I am having problems counting commas (,) from a variable in shell scripting.. the variable contains similiar to: ID@NAME@DESCRIPTION,ID@NAME@DESCRIPTION, ..... It can go on and on.. So i need to count the number of sets i.e.( ID@NAME@DESCRIPTION is one set) and process the... (4 Replies)
Discussion started by: faelric
4 Replies

7. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

8. Shell Programming and Scripting

checking a number

ok im trying to find out how many cars a user enters. Its giving me an error message of "integer expression expected" Basically if i enter any number over 0 (zero) it should continue read -p "How many cars:" carsn test $cars -ge 1 test $? -ne 0 && read -p "Invalid number.... (8 Replies)
Discussion started by: gangsta
8 Replies

9. Shell Programming and Scripting

Write $line number into textfile and read from line number

Hello everyone, I don't really know anything about scripting, but I have to manage to make this script, out of necessity. #!/bin/bash while read -r line; do #I'm reading from a big wordlist instructions using $line done Is there a way to automatically write the $line number the script... (4 Replies)
Discussion started by: bobylapointe
4 Replies

10. Shell Programming and Scripting

Cutting commas after the second occurrence in a line

Hello everyone, I am manipulating a large CSV file and am trying to read it into a program and started running into trouble. The have manually edited the file trying to make it correctly run through the program and have made progress. However, I am know stuck with an issue involving too many... (3 Replies)
Discussion started by: tastybrownies
3 Replies
tunefstab(4)						     Kernel Interfaces Manual						      tunefstab(4)

NAME
tunefstab - VxFS file system tuning parameters table DESCRIPTION
The file contains tuning parameters for VxFS file systems. sets the tuning parameters for mounted file systems by processing command line options or by reading parameters in the file. Each entry in is a line of fields in one of the following formats: block-device tunefs-options system-default tunefs-options block-device is the name of the device on which the file system is mounted. If there is more than one line that specifies options for a device, each line is processed and the options are set in order. In place of block-device, system-default specifies tunables for each device to process. If there is an entry for both a block-device and system-default, the system-default value takes precedence. Lines in that start with the pound (#) character are treated as comments and ignored. The tunefs-options correspond to the tunable parameters that and set on the file system. Each option in this list is a name=value pair. Separate the options by commas, with no spaces or tabs between the options and commas. See the vxtunefs(1M) manual page for a description of the supported options. EXAMPLES
If you have a four column striped volume, with a stripe unit size of 128 kilobytes per disk, set the and parameters 128 and four, respec- tively. You can do this in two ways: or: To set the discovered direct I/O size lower so that it is always lower than the default, add the following line to the file: FILES
Default file. SEE ALSO
mkfs_vxfs(1M), mount(1M), vxtunefs(1M). tunefstab(4)
All times are GMT -4. The time now is 10:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy