03-13-2009
Unix, a file is asciii or not
Hi,
This query might sound familiar, but I have an issue in finding out whether the file is ascii or not.
The requirement:
1. Check if the file has any only ascii ,line feed , tab. If it contains any non-ASCII it has to fail.
2. The file size will go upto 1.5GB in size.
3. The length of every line is fixed . The number of lines will be upto 1 - 2 million.
What I tried:
I tried the file utility:
-------------------------------------------------------
file "$1" | grep -Fq executable &&
printf "%s is executable.\n" "$1"
and some script suggested in this forum like
ftype=2
file "$1" | /usr/xpg4/bin/grep -Fq ascii && ftype=0
file "$1" |/usr/xpg4/bin/grep -Fq executable && ftype=1
echo $ftype
-------------------------------------------------------
The manual says it will only check for the first 512 bytes. So the above samples aren't working in my case.
Could you please let me know how this can be achieved. Do I need to read every character and check for the ascii value of that character? If yes could you please provide me some sample scripts.
Thanks in advance
Hemanth.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
My local server is :/usr/abcd/
Remote server is :/Usr/host/test/
I want to send files from local unix directory(All files starting with O_999) to
remote host unix directory.
Can any body give me the Unix Shell script to do this.
One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies
2. Shell Programming and Scripting
Hi
Can we call a jsp page from Unix.if so please let me know how we can..
thanks for the help in advance...
thanks
kumar (0 Replies)
Discussion started by: mailsukumar
0 Replies
3. Shell Programming and Scripting
unix script must do the fiollowing
open a file containing comma delimited records
> each record contains 10 fields
> removes the 2nd field and use that same field containing fields 2 to 10
the original record after fprocessing should containing fields 1 and 3
a new erecord must be... (10 Replies)
Discussion started by: dwightja
10 Replies
4. Shell Programming and Scripting
Hi Experts,
I have a requirement where i need to setup a batch job which runs everymonth and move the pdf files from unix server to windows servers.
Could some body provide the inputs for this.
and also please provide the inputs on how to map the network dirve in the unix like that... (1 Reply)
Discussion started by: ger199901
1 Replies
5. Solaris
I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command.
I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file.
Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies
6. Shell Programming and Scripting
Hi, I am new to this subject.....Can someone please help me out with the script...
unix usernm "sdhftst"
unix pwd "chsd13"
windows usernm "dfghtst"
windows pwd "chsd13"
path..../xxx/xxxxx/xxxxxx/xxxxxxx
please can u get me a script...its only one file to get ftp.
Thanks... (2 Replies)
Discussion started by: himakiran9
2 Replies
7. UNIX Desktop Questions & Answers
Hi all,
I wish to know whether Unix can access window's file in Unix's terminal?
Apart from that, how to copy files or share files between Window and Unix? I get to know of secure copy, however, my company's Unix does not support the feature of secure copy? Any other method for me to share/... (5 Replies)
Discussion started by: jessy83
5 Replies
8. Shell Programming and Scripting
Dear All,
Can someone help to command or program to transfer the file from windows to Unix server and from one unix server to another Unix server in secure way.
I would request no samba client. (4 Replies)
Discussion started by: yadavricky
4 Replies
9. What is on Your Mind?
I think i can consider myself as /dev/zero because my unix skills sucks. lol (8 Replies)
Discussion started by: csorhand
8 Replies
10. Shell Programming and Scripting
Hi All ,
I am very new to unix script.I am aware of unix commands but never put together in unix script level.If any one can suggest me technical guidance in the below scenario that will highly beneficial.
Data have been already migrated from mainframe to Hadoop file system(HDFS).HDFS server... (15 Replies)
Discussion started by: STCET22
15 Replies
LEARN ABOUT CENTOS
contents
contents(4) File Formats contents(4)
NAME
contents - list of files and associated packages
SYNOPSIS
/var/sadm/install/contents
DESCRIPTION
The file /var/sadm/install/contents is a source of information about the packages installed on the system. This file must never be edited
directly. Always use the package and patch commands (see SEE ALSO) to make changes to the contents file.
Each entry in the contents file is a single line. Fields in each entry are separated by a single space character.
Two major styles of entries exist, old style and new style. The following is the format of an old-style entry:
ftype class path package(s)
The following is the general format of a new-style entry:
path[=rpath] ftype class [ftype-optional-fields] package(s)
New-style entries differ for each ftype. The ftype designates the entry type, as specified in pkgmap(4). The format for new-style entries,
for each ftype, is as follows:
ftype s: path=rpath s class package
ftype l: path l class package
ftype d: path d class mode owner group package(s)
ftype b: path b class major minor mode owner group package
ftype c: path c class major minor mode owner group package
ftype f: path f class mode owner group size cksum modtime package
ftype x: path x class mode owner group package
ftype v: path v class mode owner group size cksum modtime package
ftype e: path e class mode owner group size cksum modtime package
A significant distinction between old- and new-style entries is that the former do not begin with a slash (/) character, while the latter
(new-style) always do. For example, the following are new-style entries:
d none /dev SUNWcsd
e passwd /etc/passwd SUNWcsr
The following are new-style entries:
/dev d none 0755 root sys SUNWcsr SUNWcsd
/etc/passwd e passwd 0644 root sys 580 48299 1077177419 SUNWcsr
The following are the descriptions of the fields in both old- and new-style entries.
path
The absolute path of the node being described. For ftype s (indicating a symbolic link) this is the indirect pointer (link) name.
rpath
The relative path to the real file or linked-to directory name.
ftype
A one-character field that indicates the entry type (see pkgmap(4)).
class
The installation class to which the file belongs (see pkgmap(4)).
package
The package associated with this entry. For ftype d (directory) more than one package can be present.
mode
The octal mode of the file (see pkgmap(4)).
owner
The owner of the file (see pkgmap(4)).
group
The group to which the file belongs (see pkgmap(4)).
major
The major device number (see pkgmap(4)).
minor
The minor device number (see pkgmap(4)).
size
The actual size of the file in bytes as reported by sum (see pkgmap(4)).
cksum
The checksum of the file contents (see pkgmap(4)).
modtime
The time of last modification (see pkgmap(4)).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsr |
+-----------------------------+-----------------------------+
|Interface Stability |Unstable |
+-----------------------------+-----------------------------+
SEE ALSO
patchadd(1M), pkgadd(1M), pkgadm(1M), pkgchk(1M), pkgmap(4), attributes(5)
NOTES
As shown above, the interface stability of /var/sadm/install/contents is Unstable (see attributes(5)). It is common practice to use this
file in a read-only manner to determine which files belong to which packages installed on a system. While this file has been present for
many releases of the Solaris operating system, it might not be present in future releases. The fully supported way to obtain information
from the installed package database is through pkgchk(1M). It is highly recommended that you use pkgchk rather than relying on the contents
file.
SunOS 5.10 29 Jun 2004 contents(4)