Tag Archives: OUTPUT

Copy an array to a newly created directory

By Rashid Khan

hello everyone,

I am trying to Create an array for storing all file names. After that create the directory (use absolute path). Then for each file name in that array, copy the file name to to scratch.

I am new to perl script and trying to develop a script as follows.

Code:

#!/usr/bin/perl

use File::Copy;

#use Archive::Zip qw( :ERROR_CODES );

$my_file = "makefile";
open(HANDLE,"<$my_file");

#$output_file = "libs.txt";
#open (OUTPUT, ">$output_file");

while()
{
if(/check_geomtools.exe:/./.lib$/)
{
@libs = split(/: /);
@nlibs = $libs[1];
mkdir "Scratch";
foreach $my_libs(@nlibs)
{
copy($my_libs, Scratch)
}

}

}

close HANDLE;


Please suggest…

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Combining two files line by line

By johankor

Hello guys, I have a problem with two text files. I want to join them line by line with a bash script if it is possible. I think an example will be much clear;

Code:

FILE 1
314.01 83.826
52.43 79.544
316.36 45.283
351.15 87.503

FILE 2
140.323 84.918
130 78.256
120 77.603
118 79.047

I want the output like below:

OUTPUT
314.01 83.826
140.323 84.918
52.43 79.544
130 78.256
316.36 45.283
120 77.603
351.15 87.503
118 79.047


I hope it is clear with the example. Both of the files are more than 500 lines long so it is really much appreciated if you can find an easy solution.

Thanks

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Copying a file using variable

By Rami Reddy

Hi this is the code
i am using copying a file by using a variable
i have a file test.txt which contains 5 lines

Code:

#!/bin/bash
#SCRIPT: method2.sh
#PURPOSE: Process a file line by line with redirected while-read loop.

FILENAME=test.txt
count=0
foldername=OUTPUT
mkdir $foldername

chmod 777 $foldername

while read LINE
do
(( count++ ))
cp $LINE $foldername/

done < $FILENAME
echo -e "nTotal $count Lines read"


now, i am getting this error

Code:

cp: cannot stat `$AP_TOP/reports/US/APXINSWP.rdf': No such file or directory
cp: cannot stat `$AP_TOP/reports/US/APXINROH.rdf': No such file or directory
cp: cannot stat `$AP_TOP/reports/US/APXWTGNR.rdf': No such file or directory
cp: cannot stat `$AP_TOP/reports/US/APXVDREV.rdf': No such file or directory
cp: cannot stat `$AP_TOP/reports/US/APXVDLBL.rdf': No such file or directory


Please help me.

Thanks

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Cat writing only one record in the output file

By sagar.cumar

Hi All,

I have an input file containing data as below:

Input.DAT

Code:

XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|AA|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111


I am executing below series of commands by validating 5th character of the input file (i.e. B in the said example).

Code:

rcnt=$(awk '{n++} END {print n}' Input.DAT)
fcnt=$(printf "%010d" $rowcount)
fnam1="OUTPUT"
fnam2="_B"
fnam3=".DAT"
nfnam=$(echo $fnam1$fnam2$fnam3)
touch $nfnam
echo "HEADER|$nfnam" > $nfnam
cat Input.DAT >> $nfnam
echo "TRAILER|$fcnt" >> $newfilename


The ouput file OUTPUT_B.DAT should contain as below:

Code:

HEADER|OUTPUT_B.DAT
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|AA|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111
TRAILER|0000000002


But, I am getting only one detailed record in the ouput file.

Can anyone please advise.
Thanks a lot in advance.
Sagar.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Ssh to remote server loop is breaking

By raghur77

hi All,

cat login.list
server1 userid1
server2 userid2
server3 userid3
—————————————-

#SSHSCRIPT.ksh
FILE=login.list

while read vah vah_id
do
ssh $vah -l $vah_id “pwd”
done < "$FILE"

—————————————–

When i execute ksh -x SSHSCRIPT.ksh it executes only one loop and exist, Please assist me here

OUTPUT:

ksh -x SSHSCRIPT.ksh
+ FILE=login.list
+ read vah vah_id
+ IFS=
+ ssh server1 -l userid1 pwd
/server1/admin
+ read vah vah_id
+ IFS=

Source: FULL ARTICLE at The UNIX and Linux Forums

Find Unmatched name from given lists..

By Killer420i have two lists,
list1 => abc jones oracle smith ssm tty
list2 => abc jones lmn smith ssm xyz

now i want to print only those names which are present in list2 and want to remove names from list2 which presents in list1.

so i want OUTPUT => lmn xyz
because “abc jones smith ssm” from list2 are present in list1.

I want to do it in shell script using loop… plz help.
Source: The UNIX and Linux Forums