Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

How to open hidden file and converted into .dat format?

Programming


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-24-2016
avi1991nash avi1991nash is offline
Registered User
 
Join Date: Oct 2016
Last Activity: 10 December 2016, 7:04 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
How to open hidden file and converted into .dat format?

Here i am having ".tmideg0"hidden file .
I have made programm but it doesnot work

Code:
#!/usr/bin/perl




$runDir = $ENV{"REGR_RUN_DIR"};
@files = (<*.tmideg0> <*.tmideg1>);

foreach $FILE (@files)
{
open (IN, $FILE) || die "Couldn't open $FILE for reading";
open (OUT, ">$runDir/$FILE.dat") || die "Couldn't open $FILE for reading";

while(<IN>) {
    print OUT $_;
}
}
close(IN);
close(OUT);

---------- Post updated at 02:43 PM ---------- Previous update was at 11:09 AM ----------

here i am having code
in which it convert all ".txt" file to ".txt.dat" file but i want ".dat file" how to do it.


Code:
#!/usr/bin/perl

$runDir = $ENV{"REGR_RUN_DIR"};
@files = (<*.txt>);

foreach $FILE (@files)
{
open (IN, $FILE) || die "Couldn't open $FILE for reading";

open (OUT, ">$runDir/$FILE.dat") || die "Couldn't open $FILE for reading";

while(<IN>) {
    print OUT $_;
}
}
close(IN);
close(OUT);

Moderator's Comments:
How to open hidden file and converted into .dat format? edit by bakunin: since Don Cragun has edited in the missing CODE-tags for you, you have appended your original post, AGAIN NOT USING CODE-TAGS! How often, do you think. we need to ask you to use them until this bears fruit?

Last edited by bakunin; 10-24-2016 at 07:21 AM.. Reason: Add CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 10-24-2016
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 26 April 2017, 12:15 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 5,407
Thanks: 99
Thanked 1,491 Times in 1,108 Posts
Quote:
Originally Posted by avi1991nash View Post
Here i am having ".tmideg0"hidden file .
I have made programm but it doesnot work
First off, "doesn't work" is not an error description becoming to a professional programmer. How did it "not work"? Core dump? File not found? Syntax error? Interpreter having a bad day? Other?

You might as well start with developing good habits and this includes: analysis of an error includes to describe everything related to it: the error messages, other diagnostic messages, description of what happened, etc., etc..

In your case most probably this:


Code:
@files = (<*.tmideg0> <*.tmideg1>);

is the culprit: file(name)s starting with a "." are not expanded by usual file globs. Try:


Code:
@files = (<.*tmideg0> <.*tmideg1>);

to include files starting with a "." and ending in "tmideg0", i.e. ".tmideg0", ".bla-footmideg0", etc. into your glob.

I hope this helps.

bakunin
Sponsored Links
    #3  
Old Unix and Linux 10-24-2016
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 28 April 2017, 5:34 AM EDT
Location: San Jose, CA, USA
Posts: 10,220
Thanks: 513
Thanked 3,546 Times in 3,019 Posts
I am certainly not an expert using perl, but for your original problem, please try changing:

Code:
@files = (<*.tmideg0> <*.tmideg1>);

to:

Code:
@files = (<.tmideg0>, <.tmideg1>);

or:

Code:
@files = (<.tmideg[01]>);

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date format change in UNIX .dat file karthikengox Shell Programming and Scripting 18 06-16-2014 02:24 AM
Tar to decompress and to convert file to .dat format vedanta Shell Programming and Scripting 2 04-19-2013 03:47 AM
How to Open a data format file? Adhi UNIX for Dummies Questions & Answers 4 01-24-2013 05:00 PM
/etc/format.dat file currupt lbreddy Solaris 3 05-15-2009 03:09 PM
How to open a .DAT video file in LINUX mahi3699 Linux 1 08-24-2006 10:39 AM



All times are GMT -4. The time now is 01:51 PM.