04-08-2008
Ksh Storing Multiple Files and reading each line in each file.
How would I go about storing multiple file paths in a directory that begin like: 20080402*
and run a loop that reads each line of each file thats in a given directory. So far this is what I have:
#!/bin/ksh
echo "ENTER Reprint Date (YYYYMMDD): "
read ReprintDate
echo ""
ReprintDateCount=$(echo ${ReprintDate} | wc -m)
if [[ $ReprintDateCount -ne 9 ]]
then
echo "INVALID Reprint Date! ${ReprintDateCount}"
echo "RE-ENTER Reprint Date (YYYYMMDD): "
read ReprintDate
fi
echo "ENTER SITE Code Selection (ALL, A, T, M, K, L, P, and O): "
read SiteCode
echo ""
if [[ $SiteCode != "ALL" || $SiteCode != "all" || $SiteCode != "A" || $SiteCode != "a" || $SiteCode != "T" || $SiteCode != "t" || $SiteCode != "M" || $SiteCode != "m" || $SiteCode != "K" || $SiteCode != "k" || $SiteCode != "L" || $SiteCode != "l" || $SiteCode != "P" || $SiteCode != "p" || $SiteCode != "O" || $SiteCode != "o" ]]
then
echo "INVALID SITE Code Selection!"
echo "RE-ENTER SITE Code Selection (ALL , A, T, M, K, L, P, and O): "
read SiteCode
echo ""
fi
filename=~/${ReprintDate}220032*
echo "Reprint Request File: "$filename
echo ""
{ while read myline
do
if [[ ${myline} != H* && ${myline} != T* ]]
then
if [[ $myline = D* ]]
then
zipcode=$(echo ${myline} | sed 's/^[ \t]*//;s/[ \t]*$//')
zipcode=${zipcode#${zipcode% *}}
zipcount=$(echo ${zipcode} | wc -m)
state=${myline%$zipcode*}
state=$(echo ${state} | sed 's/^[ \t]*//;s/[ \t]*$//')
state=${state#${state% *}}
statecount=$(echo ${state} | wc -m)
city=${myline%$state*}
city=$(echo ${city} | sed 's/[ \t]*$//')
city=${city#${city% *}}
citycount=$(echo ${city} | wc -m)
if [[ $zipcode -lt 1 ]] && [[ $zipcode -gt 99999 ]] || [[ $zipcount -ne 6 ]]
then
echo ${myline}
echo "ZIPCODE WARNING! -> ${zipcode}"
fi
if [[ $statecount -ne 3 ]]
then
echo ${myline}
echo "STATE WARNING! -> ${state}"
fi
if [[ $citycount -lt 4 ]]
then
echo ${myline}
echo "CITY WARNING! -> ${city}"
fi
fi
fi
done } < $filename
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi -
I have a file that contains data in this format:-
#comment
value1 value2 value3
#comment
value4 value5 value6 value7
#comment
value8 value9
I need to read value1, value2 and value3 into one array, value4 value5 value6 and value7 into another array and value8 and value9 into a 3rd... (2 Replies)
Discussion started by: sniper57
2 Replies
2. Shell Programming and Scripting
Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me .
Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer.
I want to create a mutiple output files with each file having a... (2 Replies)
Discussion started by: bhargavkr
2 Replies
3. Shell Programming and Scripting
Hi,
I have a folder which contains multiple config.xml files and one input file, Please see the below format.
Config Files format looks like :-
Code:
<application name="SAMPLE-ARCHIVE">
<NVPairs name="Global Variables">
<NameValuePair>
... (0 Replies)
Discussion started by: haiksuresh
0 Replies
4. Shell Programming and Scripting
Hi folks,
I'm using bash and would like to do the following. I would like to read some values from the file and store it in the variable and use it.
My file is 1.txt and its contents are
VERSION=5.6
UPDATE=4
I would like to read "5.6" and "4" and store it in a variable in shell... (6 Replies)
Discussion started by: scriptfriend
6 Replies
5. Shell Programming and Scripting
consider the small piece of code
while read line
do
echo $line
done < example
content of example file
sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr
the output is like
sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr
the... (4 Replies)
Discussion started by: Kesavan
4 Replies
6. Programming
Hi,
I am trying to read a set of numbers that are in scientific notation into a file so I can do some math on them, but when I display the array contents the numbers aren't the same as the numbers in the file.
Could someone explain why? Thanks.
int main()
{
double fArray;
... (3 Replies)
Discussion started by: Filter500
3 Replies
7. Shell Programming and Scripting
I am working on a script for Mac OS X that, among many other things, gets a list of all the installed Applications. I am pulling the list from the system_profiler command and formatting it using grep and awk. The problem is that I want to be able to use each result individually later in the script.... (3 Replies)
Discussion started by: cranfordio
3 Replies
8. Shell Programming and Scripting
I have a environment property file which contains:
Input file:
value1 = url1
value2 = url2
value3 = url3 and so on.
I need to search all *.xml files under directory for value1 and replace it with url1.
Same thing I have to do for all values mentioned in input file. I need script in unix bash... (7 Replies)
Discussion started by: Shamkamde
7 Replies
9. Shell Programming and Scripting
Hi All,
I have a file queries.txt as follows :
SELECT COLUMN1 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN1 FROM SCDEMA2.TABLE2;
SELECT COLUMN2 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN2 FROM SCDEMA2.TABLE2;
SELECT COLUMN3 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN3 FROM SCDEMA2.TABLE2;
SELECT... (2 Replies)
Discussion started by: SriRamKrish
2 Replies
10. Shell Programming and Scripting
I am looking for help in processing of those options: '-n' or '-p'
I understand what they do and how to use them.
But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.)
I did try it and -n works on 2 files.
Question is:
- is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies
LEARN ABOUT HPUX
systemd-delta
SYSTEMD-DELTA(1) systemd-delta SYSTEMD-DELTA(1)
NAME
systemd-delta - Find overridden configuration files
SYNOPSIS
systemd-delta [OPTIONS...] [PREFIX[/SUFFIX]|SUFFIX...]
DESCRIPTION
systemd-delta may be used to identify and compare configuration files that override other configuration files. Files in /etc have highest
priority, files in /run have the second highest priority, ..., files in /usr/lib have lowest priority. Files in a directory with higher
priority override files with the same name in directories of lower priority. In addition, certain configuration files can have ".d"
directories which contain "drop-in" files with configuration snippets which augment the main configuration file. "Drop-in" files can be
overridden in the same way by placing files with the same name in a directory of higher priority (except that, in case of "drop-in" files,
both the "drop-in" file name and the name of the containing directory, which corresponds to the name of the main configuration file, must
match). For a fuller explanation, see systemd.unit(5).
The command line argument will be split into a prefix and a suffix. Either is optional. The prefix must be one of the directories
containing configuration files (/etc, /run, /lib, ...). If it is given, only overriding files contained in this directory will be shown.
Otherwise, all overriding files will be shown. The suffix must be a name of a subdirectory containing configuration files like tmpfiles.d,
sysctl.d or systemd/system. If it is given, only configuration files in this subdirectory (across all configuration paths) will be
analyzed. Otherwise, all configuration files will be analyzed. If the command line argument is not given at all, all configuration files
will be analyzed. See below for some examples.
OPTIONS
The following options are understood:
-t, --type=
When listing the differences, only list those that are asked for. The list itself is a comma-separated list of desired difference
types.
Recognized types are:
masked
Show masked files
equivalent
Show overridden files that while overridden, do not differ in content.
redirected
Show files that are redirected to another.
overridden
Show overridden, and changed files.
extended
Show *.conf files in drop-in directories for units.
unchanged
Show unmodified files too.
--diff=
When showing modified files, when a file is overridden show a diff as well. This option takes a boolean argument. If omitted, it
defaults to true.
-h, --help
Print a short help text and exit.
--version
Print a short version string and exit.
--no-pager
Do not pipe output into a pager.
EXAMPLES
To see all local configuration:
systemd-delta
To see all runtime configuration:
systemd-delta /run
To see all system unit configuration changes:
systemd-delta systemd/system
To see all runtime "drop-in" changes for system units:
systemd-delta --type=extended /run/systemd/system
EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise.
SEE ALSO
systemd(1), systemd.unit(5)
systemd 237 SYSTEMD-DELTA(1)