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


 
Thread Tools Search this Thread
Top Forums Programming How to open hidden file and converted into .dat format?
# 1  
Old 10-24-2016
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:
Mod Comment 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 08:21 AM.. Reason: Add CODE tags.
# 2  
Old 10-24-2016
Quote:
Originally Posted by avi1991nash
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
# 3  
Old 10-24-2016
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]>);

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync - how to copy hidden folder or hidden files when using full path

Hello. I use this command : rsync -av --include=".*" --dry-run "$A_FULL_PATH_S" "$A_FULL_PATH_D"The data comes from the output of a find command. And no full source directories are in use, only some files. Source example... (2 Replies)
Discussion started by: jcdole
2 Replies

2. Shell Programming and Scripting

How to use 'ls' command to list files like *.dat, not *.*.dat?

How to use 'ls' command to list files like *.dat, not *.*.dat (5 Replies)
Discussion started by: pmcginni777
5 Replies

3. Programming

Python Results Converted To C Struct Header File

I created python code that produce output in the form of: moses-red-sea=1.00.03 genesis-snake=2.03 deliverance=5.0.010 I need to take this output and create a "C" header file and have it look like this: struct { char *name; char *fixed_version; } filename_versions... (7 Replies)
Discussion started by: metallica1973
7 Replies

4. Shell Programming and Scripting

Date format change in UNIX .dat file

Hi, I need help to convert the date format in .DAT file in unix. I want to convert 10@@|SWIFT MT568 Extract@@|Apr 14 2014 5:47:52:563PM@@|Apr 14 2014 4:33:47:663PM@@||##| into 10@@|SWIFT MT568 Extract@@|04/14/2014/ 5:47:52:563PM@@|04/14/2014 4:33:47:663PM@@||##| Appreciate... (18 Replies)
Discussion started by: karthikengox
18 Replies

5. Shell Programming and Scripting

Tar to decompress and to convert file to .dat format

tar -tvf abc.tar.gz gives me the file name abc.Is it possible to rename the file to abc.dat while decompressing using tar ? Thanks. (2 Replies)
Discussion started by: vedanta
2 Replies

6. UNIX for Dummies Questions & Answers

How to Open a data format file?

Hi, Am having a file. I checked that file format by the following command file filename Output is filename: data So the file is data format file Am trying to view that file so i have used some commands like cat,more so on but it showing the contents like compressed form(full of Symbols). How... (4 Replies)
Discussion started by: Adhi
4 Replies

7. UNIX for Dummies Questions & Answers

List all directories hidden or not hidden

I want to list all directories hidden or not hidden. ls -ld */ => shows only not hidden directories so i guess the answer would be to add the a option to show all files ls -lad */ => not working :confused: ls -la | grep "^d" => works But I would like to know why I can't use ls -lad... (4 Replies)
Discussion started by: servus
4 Replies

8. Solaris

/etc/format.dat file currupt

What we have to do when the /etc/format.dat file is corrupted? (3 Replies)
Discussion started by: lbreddy
3 Replies

9. Linux

How to open a .DAT video file in LINUX

:confused: Hai guys!!!! I am using Mandrake Linux 10.1 with Intel P4 system.. I don't know how to open .DAT video file in LINUX. Please help me! (1 Reply)
Discussion started by: mahi3699
1 Replies
Login or Register to Ask a Question