Sponsored Content
Top Forums Shell Programming and Scripting If else condition inside for loop of awk command in UNIX shell scripting Post 302849467 by karthikram on Sunday 1st of September 2013 10:59:14 PM
Old 09-01-2013
Hi Scott,

Thanks it worked.

Thanks,
Regards,
karthikram
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking condition inside the loop

Hi all, I have one clarification i am using the loop which will process for each record .suppose there is f ailure in the first record it need to send mail and process the next .my code: defcount=`cat <filename>|wc -l` while ] do if <some condiotion> then echo "mail" fi done so... (1 Reply)
Discussion started by: ithirak17
1 Replies

2. Shell Programming and Scripting

condition inside a for loop

I have a for loop in my script as shown below. for file_path in $file_list ; do ........my code .......... ...... done Can i restrict the number of files parsing to the variable file_path as 50? That is, even if I have some 100 files in file_list, I need to take only 50 files for... (7 Replies)
Discussion started by: Vijay06
7 Replies

3. Shell Programming and Scripting

using flag inside a for loop to check condition

I have a logic like this It initializes the flag variable as "T" at the beginning of the loop everytime Inside each loop it checks for two conditions and updates the flag variable as "A" or "B" In the end of the loop it checks for the value of the variable flag for "A" or "B" and execute... (4 Replies)
Discussion started by: codeman007
4 Replies

4. Shell Programming and Scripting

C Shell - Command Inside a Loop

I have a command nested in some while loops to parse some data that looks something like this. while ($condition) while ($condition) ... gzcat /dir/$fileName.gz | grep $searchString > out_file end end On the first loop, the command is executed properly (and takes maybe 10... (3 Replies)
Discussion started by: hobbers
3 Replies

5. Shell Programming and Scripting

Error while using sqlplus command inside 'if' condition in an unix shell script

Hi all, I am using the below given sqlplus command in my unix script to invoke a stored procedure which returns a value .It works fine. RET_CODE=$(/opt/oracle/product/10.2.0.4.CL/bin/sqlplus -S $USER/$PASSWD@$DB_NAME <<EOF EXEC MY_PKG.MY_SP (:COUNT); PRINT COUNT; commit; ... (6 Replies)
Discussion started by: Shri123
6 Replies

6. Shell Programming and Scripting

Check condition inside the loop

Hi, I am in trouble. I can get inside my condition test inside a loop : I am in ksh (solaris) while read file do <commande to retrieve file> >> ${LOG_RETRIEVE_FILE.log} msg_err=$(cat ${LOG_RETRIEVE_FILE.log} | grep "error retrieve") if ; then <sendmail> exit 1 fi done I tried... (6 Replies)
Discussion started by: Aswex
6 Replies

7. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

8. Shell Programming and Scripting

how to use split command in unix shell with a condition

Hi all, I have a file which I want to split into several files based on a condition. This files has several records. I want one record per file. Each record ends with a //. So, I want to separate files based on this condition. I want split files to be named with the name across the field ID (for... (2 Replies)
Discussion started by: kaav06
2 Replies

9. Shell Programming and Scripting

How to pass current year and month in FOR LOOP in UNIX shell scripting?

Hi Team, I have created a script and using FOR LOOP like this and it is working fine. for Month in 201212 201301 201302 201303 do echo "Starting the statistics gathering of $Month partitions " done But in my scripts the " Month " variable is hard-coded. Can you please any one... (3 Replies)
Discussion started by: shoan
3 Replies

10. Shell Programming and Scripting

How to get the for loop output from a remote server in UNIX shell scripting?

Hi, I am using ksh , when i try to use for loop i am getting the expected output. $for variable in $(ps -fu user | grep -i something/ | grep -i something | grep -v grep | awk '{print $2}');do > grep $variable /tmp/some_path/*/* > done when tried the below to remote server, getting... (4 Replies)
Discussion started by: karthikram
4 Replies
Dirent(3pm)						User Contributed Perl Documentation					       Dirent(3pm)

NAME
IO::Dirent - Access to dirent structs returned by readdir SYNOPSIS
use IO::Dirent; ## slurp-style opendir DIR, "/usr/local/foo"; my @entries = readdirent(DIR); closedir DIR; print $entries[0]->{name}, " "; print $entries[0]->{type}, " "; print $entries[0]->{inode}, " "; ## using the enumerator opendir DIR, "/etc"; while( my $entry = nextdirent(DIR) ) { print $entry->{name} . " "; } closedir DIR; DESCRIPTION
readdirent returns a list of hashrefs. Each hashref contains the name of the directory entry, its inode for the filesystem it resides on and its type (if available). If the file type or inode are not available, it won't be there! nextdirent returns the next dirent as a hashref, allowing you to iterate over directory entries one by one. This may be helpful in low- memory situations or where you have enormous directories. IO::Dirent exports the following symbols by default: readdirent nextdirent The following tags may be exported to your namespace: ALL which includes readdirent, nextdirent and the following symbols: DT_UNKNOWN DT_FIFO DT_CHR DT_DIR DT_BLK DT_REG DT_LNK DT_SOCK DT_WHT These symbols can be used to test the file type returned by readdirent in the following manner: for my $entry ( readdirent(DIR) ) { next unless $entry->{'type'} == DT_LNK; print $entry->{'name'} . " is a symbolic link. "; } For platforms that do not implement file type in its dirent struct, readdirent will return a hashref with a single key/value of 'name' and the filename (effectively the same as readdir). This is subject to change, if I can implement some of the to do items below. CAVEATS
This was written on FreeBSD and OS X which implement a robust (but somewhat non-standard) dirent struct and which includes a file type entry. I have plans to make this module more portable and useful by doing a stat on each directory entry to find the file type and inode number when the dirent.h does not implement it otherwise. Improvements and additional ports are welcome. TO DO
o For platforms that do not implement a dirent struct with file type, do a stat on the entry and populate the structure anyway. o Do some memory profiling (I'm not sure if I have any leaks or not). COPYRIGHT
Copyright 2002, 2011 Scott Wiersdorf. This library is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License. AUTHOR
Scott Wiersdorf, <scott@perlcode.org> ACKNOWLEDGEMENTS
Thanks to Nick Ing-Simmons for his help on the perl-xs mailing list. SEE ALSO
dirent(5), perlxstut, perlxs, perlguts, perlapi COPYRIGHT AND LICENSE
Copyright (C) 2007 by Scott Wiersdorf This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2011-08-22 Dirent(3pm)
All times are GMT -4. The time now is 07:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy