Sponsored Content
Top Forums Shell Programming and Scripting Need some help on scripting for validating the files before loading Post 302598202 by chihung on Monday 13th of February 2012 07:40:14 PM
Old 02-13-2012
1. Assuming the file extension is csv
Code:
if [ "${filename##*.}" != "csv" ]; then
  echo "$filename extension is not .csv"
  exit 1
fi
if [ !-r $filename ]; then
  echo "$filename does not exist or readable"
  exit 1
fi


Delimiter
Code:
awk -F";" 'NF!=10{exit(1)}' $filename
if [ $? -eq 1 ]; then
  echo "$filename does not contain 10 records in each row"
  exit 1

As for the "confirm name, number and order of the columns.", pls elaborate with examples.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

validating dates

This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor. I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... ... (2 Replies)
Discussion started by: MizzGail
2 Replies

2. Shell Programming and Scripting

Validating $1 and $2 before using

Hi there, I'm trying to validate my $1 and $2 before I use them in the sqlplus update, I think I have the validation rules set correctly??? however when I test my script, it jumps straight into the sql. It doesn't seem to validate the vars....even when I know they are incorrect. if ; then ... (6 Replies)
Discussion started by: nhatch
6 Replies

3. Shell Programming and Scripting

validating 10. IP address any way possible

HELP: validating IP addresses any way possible -------------------------------------------------------------------------------- I am trying to validate input from the user in a script. I thought is was easy to do using regular expressions but I can't figure out how to use REs in a... (1 Reply)
Discussion started by: nrodolfich
1 Replies

4. Shell Programming and Scripting

Function loading in a shell scripting like class loading in java

Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ... thanks in advance.. (1 Reply)
Discussion started by: mpsc_sela
1 Replies

5. Shell Programming and Scripting

loading Binary files with SQLLDR

Hi, Can anyonr please tell how to load a binary file through SQLLDR. I have the structure of the binary file in a seperate lb file but I don't know how to feed it to the sqlldr. (0 Replies)
Discussion started by: snowline84
0 Replies

6. Shell Programming and Scripting

Validating IP address.

Hi All, This is a small snippet that I am using to validate the format of IP address.This is working fine. Since this is not elegant, please let me know if anyone has a better working code than the one below. Also I am planning to ping the ip address given by the user and check the $?... (3 Replies)
Discussion started by: nua7
3 Replies

7. UNIX for Advanced & Expert Users

Loading files incrementaly

Hi Am trying to sftp this way UnixBoxA----->UnixBoxB My code will run on UnixBoxB, it will make a secure connection and pull the files from UnixBoxA. Apart from that I do not have any access on UnixBoxA Now UnixBoxA will receive the files daily, the file format will be... (0 Replies)
Discussion started by: hemanty4u
0 Replies

8. UNIX for Advanced & Expert Users

Help with loading config files

Hi All, I'm bit confused with a script Any help would be appreciated I have a config file say config.cfg and iam loading config file in My_Script.sh..The script name is My_Script.sh. My_Script.sh and config.cfg are in same directory...My_Script.sh is run on the crontab 50 01 * * * &&... (2 Replies)
Discussion started by: selvam
2 Replies

9. Shell Programming and Scripting

Validating files using server name and directory

Hi, I want to check if a file is a regular file or not using server name and file path. Example: I want to check whether //<server_name>/home/chandan/abc.txt is a regular file or not. Need your help!!. Thanks (3 Replies)
Discussion started by: ChandanN
3 Replies

10. UNIX for Dummies Questions & Answers

When loading Linux "loading please wait.." then nothing?

Hi everyone, I have a problem but I have never installed a separate OS before so my lingo and understanding may not be as good as some of you. I will try and explain my problem best I can. I am trying to instead of loading Windows 7 when my computer starts up, for it to start linux specifically... (2 Replies)
Discussion started by: markhow30
2 Replies
SETCAP(8)						      System Manager's Manual							 SETCAP(8)

NAME
setcap - set file capabilities SYNOPSIS
setcap [-q] [-v] (capabilities|-|-r) filename [ ... capabilitiesN fileN ] DESCRIPTION
In the absence of the -v (verify) option setcap sets the capabilities of each specified filename to the capabilities specified. The -v option is used to verify that the specified capabilities are currently associated with the file. The capabilities are specified in the form described in cap_from_text(3). The special capability string, '-', can be used to indicate that capabilities are read from the standard input. In such cases, the capabil- ity set is terminated with a blank line. The special capability string, '-r', is used to remove a capability set from a file. The -q flag is used to make the program less verbose in its output. EXIT CODE
The setcap program will exit with a 0 exit code if successful. On failure, the exit code is 1. SEE ALSO
cap_from_text(3), cap_set_file(3), getcap(8) 24th October 2008 SETCAP(8)
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy