Sponsored Content
Top Forums Shell Programming and Scripting Make Multile line is one line using window Perl Post 302750149 by adisky123 on Monday 31st of December 2012 09:43:31 AM
Old 12-31-2012
Finally this thread ends up with this working code
Code:
my $new='';
$flat_file='flat_file.csv';
$new_file='new_file.csv';

open('NEW',"<$new_file") || die "Error open file $new_file\n";
open('NEW1',">$flat_file") || die "Error open file $flat_file\n";

  while (my $s2=<NEW>) {
       chomp($s2);
      if($s2 =~ /ESP Client/){
        print NEW1 "$new\n"; $new='';
                $new=$s2;
      }
      else{
          $new = $new.$s2;
      }
   }
    close(NEW);
    close(NEW1);

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multile Pattern Search in a same line and delete

HI Gurus, I need to delete a line from a syslog file, if it matches three conditions. Say for ex., if the device name is device.name.com and if it contains the syslog message PAGP-5-PORTFROMSTP in between the time period 00:00:00 to 04:00:00, then the particular line has to be deleted from... (2 Replies)
Discussion started by: sasree76
2 Replies

2. Shell Programming and Scripting

make multiple line containing a pattern into single line

I have the following data file. zz=aa azxc-1234 aa=aa zz=bb azxc-1234 bb=bb zz=cc azxc-1234 cc=cc zz=dd azxc-2345 dd=dd zz=ee azxc-2345 ee=ee zz=ff azxc-3456 ff=ff zz=gg azxc-4567 gg=gg zz=hh azxc-4567 hh=hh zz=ii azxc-4567 ii=ii I want to make 2nd field pattern matching multiple lines... (13 Replies)
Discussion started by: VTAWKVT
13 Replies

3. Shell Programming and Scripting

Perl script to search a line and copy it to another line

Hi I have a log file (say log.txt). I have to search for a line which has the string ( say ERROR) in the log file and copy 15 lines after this into another file (say error.txt). Can someone give me the code and this has to be in PERL Thanks in advance Ammu (3 Replies)
Discussion started by: ammu
3 Replies

4. Shell Programming and Scripting

PERL or SHELL Scrript to search in Directories by taking line by line from a text file

Unix box server version *********** >uname -r B.11.00 >echo $SHELL /usr/bin/ksh --> in this server, I have the path like /IMbuild/dev/im0serv1 ---> in that directory I have the folders startup(.jsp files nearly 100 jsp's ) and scripts(contains .js files nearly 100 files) ... (9 Replies)
Discussion started by: pasam
9 Replies

5. Shell Programming and Scripting

perl: comparision of field line by line in two files

Hi everybody, First I apologize if my question seems demasiad you silly, but it really took 4 days struggling with this, I looked at books, forums ... And Also ask help to a friend that is software developer and he told me that it is a bad idea do it by perl... but this is my problem. I moved to... (8 Replies)
Discussion started by: Thelost
8 Replies

6. Shell Programming and Scripting

Perl how to compare two pdf files line by line

Hi Experts, Would really appreciate if anyone can guide me how to compare two pdf files line by line and report the difference to another file. (3 Replies)
Discussion started by: prasanth_babu
3 Replies

7. Shell Programming and Scripting

Perl : Assigning multile hash values to a single array

I know that @food = %fruit; Works. But how do I assign %fruit and %veggies to @food ? (2 Replies)
Discussion started by: popeye
2 Replies

8. Shell Programming and Scripting

Perl to extract information from a file line by line

In the below perl code I am using tags within each line to extract certain information. The tags that are used are: STB >0.8 is STRAND BIAS otherwise GOOD FDP is the second number GO towards the end of the line is read into an array and the value returned is outputed, in the first line that... (1 Reply)
Discussion started by: cmccabe
1 Replies

9. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

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

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
ln(1)							      General Commands Manual							     ln(1)

NAME
ln - link files and directories SYNOPSIS
file1 new_file file1 [file2]... dest_directory directory1 [directory2]... dest_directory DESCRIPTION
The command links: o file1 to a new or existing new_file, o file1 to a new or existing file named file1 in existing dest_directory, o file1, file2, ... to new or existing files of the same name in existing dest_directory, o directory1, directory2, ... to new directories of the same name in existing dest_directory, o or it creates symbolic links between files or between directories. If links are to dest_directory, corresponding file or directory names in that directory are linked to file1, file2, ..., or directory1, directory2, ..., etc., as appropriate. If two or more existing files or directories (excluding destination file name new_file) are speci- fied, the destination must be a directory. If new_file already exists as a regular file (or link to another file), its contents (or the existing link) and its ACL are destroyed only if the option is specified. The ACL on the new_file after the link is the same as that of the source_file file. If the and options are specified and the link being created is the name of an existing link or ordinary file and the access permissions of the file forbid writing, asks permission to overwrite the file. If the access permissions of the directory forbid writing, aborts and returns with the error message: (even if the file is an ordinary file and not a link to another file). When asking for permission to overwrite an existing file or link, prints the mode (see chmod(2) and below), followed by the first letters of the words and in the current native language, prompting for a response, and reading one line from the standard input. If the response is affirmative and is permissible, the operation occurs; if not, the command proceeds to the next source file, if any. Hard links are created with the same ownerships and permissions as the file or directory to which they are linked. If ownership or permis- sions are changed on a link or file, the same changes appear on corresponding hard links. The command does not permit hard links to a directory. Symbolic links are created with the ownership of the creator and the permissions are of the creator's current umask. Once created, the symbolic link ownership and permissions will not change, since the mode and ownership of the symbolic link is ignored by the system. If file1 is a file and new_file is a link to an existing file or an existing file with other links, new_file is disassociated from the existing file and links and linked to file1. When creates a link to a new or existing file name, ownerships and permissions are always identical to those for the file to which it is linked. If or is used to change ownership or permissions of a file or link, the change applies to the file and all associated links. The last modification time and last access time of the file and all associated links are identical (see chown(1) and chmod(1)). For a discussion of symbolic links, see symlink(4). Options The command recognizes the following options: Force existing destination path names to be removed to allow the link. Write a prompt to the standard error output requesting confirmation for each link that would overwrite an existing file. This option takes effect only if used in con- junction with the option. Cause to create symbolic links instead of the usual hard links. A symbolic link contains the name of the file to which it is linked. The referenced file is used when an operation is performed on the link (see open(2)). A on a symbolic link returns the linked-to file; an must be performed to obtain information about the link (see stat(2)). A call can be used to read the contents of the symbolic link (see readlink(2)). Symbolic links may span file systems and refer to directories. Access Control Lists (ACLs) If optional ACL entries are associated with new_file, displays a plus sign after the access mode when asking permission to overwrite the file. If new_file is a new file, it inherits the access control list of file1, altered to reflect any difference in ownership between the two files (see acl(5) and aclv(5)). In JFS file systems, new files created by do not inherit their parent directory's default ACL entries (if any), but instead retain their original ACLs. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text as single byte and/or multibyte characters. and determine the local language equivalent of (for yes/no queries). determines the language in which messages are displayed. If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari- able. If is not specified or is set to the empty string, a default of (see lang(5)) is used instead of If any internationalization vari- able contains an invalid setting, behaves as if all internationalization variables are set to See environ(5). International Code Set Support Single byte and multibyte character code sets are supported. EXAMPLES
The following command creates and in which are linked back to the original files and If and/or exists in the destination directory, it is removed and replaced by a link to or respectively. If existing file or is a link to another file or a file with links, the existing file remains. Only the link is broken and replaced by a new link to or WARNINGS
does not create hard links across file systems. DEPENDENCIES
NFS Access control lists of networked files are summarized (as returned in by but not copied to the new file. When using on such files, a is not printed after the mode value when asking for permission to overwrite a file. AUTHOR
was developed by AT&T, the University of California, Berkeley and HP. SEE ALSO
cp(1), cpio(1), mv(1), rm(1), link(1M), readlink(2), stat(2), symlink(2), symlink(4), acl(5), aclv(5). STANDARDS CONFORMANCE
ln(1)
All times are GMT -4. The time now is 10:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy