I have the following script:
This script reads in all csv files in the current directory and prints the date, time and complete contents to screen.
A filename is composed of a name, a date, a time and a suffix ".csv". So a filename could be foo_20080909_120345.csv
Upon running this, the @dt array holds:
- $dt[0] = "foo"
- $dt[1] = 20080909
- $dt[2] = 120345
So line 9 (print $dt[1] . $dt[2] . ",$_\n") yields lines of the following:
"20080909 120345,[...rest of the record...]"
where it should yield:
"2008-09-09 12:03:45,[...rest of the record...]"
How do I enter dashes ("-") and colons (":") at the right places without using contrived code such as:
substr($dt[1], 0, 4) . "-" . substr($dt[1], 4, 2) . "-" . substr($dt[1], 6, 2)
and that is just for the date.
I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open())
I would like to run another PERL-script from first one, not... (1 Reply)
greetings all, I have a task right now that is somewhat stumping me, and I am not sure what the best approach is to take it.
I have a text file that will contain something similar to the following:
first1, other1
first2, other2
first3, other3
first4, other4
I have to generate an... (14 Replies)
A record contains 50 fields separated by "~". I need to assign each of these fields to different variables. Following is the shell script approach I tried.
RECORD="FIELD1~FIELD2~FIELD3~FIELD4~FIELD5~...........~FIELD50"
VAR1=$(echo ${RECORD} | cut -d"~" -f 1)
VAR2=$(echo ${RECORD} | cut... (5 Replies)
Hi All,
I have files with a column which has values and ranges, for example
colA colB
ERD1 3456
ERD2
ERD3 4456
I want to have the following output
colA colB colC
ERD1 3456 3456
ERD2 526887 526890
ERD3 4456 4456
Being a newbie to... (2 Replies)
in bash:
LIST=`cat $1`
for i in $LIST
do
...
done
how will i do this in perl ?
$1 is my first arguement. I'm a newbie in perl and will appreciate much your help guys ... (4 Replies)
I am using MKS tool kit on windows server. One config variable is defined in windows environment and I am trying to use that variable.
# Below RootDir is defined in windows
RootDir="\\f01\var"
# in unix script
details="$RootDir/src|$RootDir/tgt"
src=`echo $details|awk -F '|' '{print... (1 Reply)
I would like to parse through some logs looking for things like exception or failed (grep -i failed). Ideal would be if it were in a menu format so someone without unix ability could just choose option 1 2 or 3 etc. If I could pass the hostname to a variable also that would be awesome, so someone... (5 Replies)
Hi all:
I have a directory where all of the subdirectories are named by the convention "images_#1:#2_Date." My goal is to get an array for each subdirectory that has the structure (#1,#2, int). I am able to use awk to print each subdirectory's values, but cannot figure out how to get them into an... (6 Replies)
suppose i have a file value where it returns 3 values
a=1 b=2 c=4
when i run it.
i am using this file in my shell script. how do i parse and get the value of a b and c? (3 Replies)