txt files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting txt files
# 1  
Old 04-17-2008
Question txt files

How can I know if a file contain text or no?

PS: I have to do a script that search for a pattern in text files
# 2  
Old 04-17-2008
Hammer & Screwdriver Perhaps take a look at 'man test'

You can try to do:

Code:
> cat checkfile 
#! /bin/bash

if [ -f sample.txt ]
   then
   echo "ordinary file"
fi
if [ -s sample.txt ]
   then 
   echo "non-zero length file"
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two txt files,mismatches will be in new txt files

Hi, Below are the sample data for txt files. txt file 1 Partnumber|catgroup_id 10001082|46016 10001093|4680 10001093|386003 10001093|463004 10003251|683 10003251|63005 10003252|463005 10003252|4683 10003260|463005 10003260|4683 10003264|4683 10003264|463005 13420000|67... (5 Replies)
Discussion started by: Ankita Talukdar
5 Replies

2. Shell Programming and Scripting

Comparing two .txt files

i am working on a shell script and need help in the comparing part of it. for e.g. there two text files like this: file1.txt Code: name1 name2 name3 file1 has to be comared with file2 defaultfile.txt Code: name1 name2 (16 Replies)
Discussion started by: draghun9
16 Replies

3. UNIX for Dummies Questions & Answers

How to tar all files except logs and .txt files

Hi I greatly appreciate the forum and the people here very helpful :) I could able to tar all the directories, sub dirs and the files. But unable to tar all the directories excluding the log and text files. Can anyone please advise the exact command to use for excluding .log and .txt? PS:... (4 Replies)
Discussion started by: Olivia
4 Replies

4. Shell Programming and Scripting

moving the files in a.txt files to a different directory

HI All, I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing. now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Discussion started by: subhasri_2020
5 Replies

5. Shell Programming and Scripting

awk-files in a txt

There is a file that contains access's data to a web server. Each line of the file (it's big) it's : IP Client - - "Command Path Protocol" code size "client software" Example,for the first line: IP Client is 67.195.37.107, date-hour is , Command Path Protocol is "Get /papers/ISO4nm.pdf ... (1 Reply)
Discussion started by: Mark_orig
1 Replies

6. Shell Programming and Scripting

Compare two txt files

Hi, I want to compare two txt files and output the matches to a file. For example I have FILE1 - accounts1.txt Peter norman elektra table CHAIR Newman nOvice FILE2 - accounts2.txt noland trainfil peter Newman norman neverlan CHAIR jackson KelSo (4 Replies)
Discussion started by: novice_sn6
4 Replies

7. UNIX for Dummies Questions & Answers

Renaming of .txt files

Hi Guys, I am a newbie to Unix . I am going through Unix Commands. I have a issue . Please try to find a solution for this... Example: I am in my current directory now which contains a folder name 'Test' . The folder Test contains some files with .txt extension.Inside the Test... (5 Replies)
Discussion started by: mraghunandanan
5 Replies

8. Solaris

list files .txt and .TXT in one command

Dear experts, In a directory i have both *.TXT and *.txt files. I have a script- for file in `ls *.txt`; do mv $file /tmp/$file How to list both *.txt and*.TXT file in one command so that script will move both .txt or .TXT whatever it find. br//purple (4 Replies)
Discussion started by: thepurple
4 Replies

9. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

10. Shell Programming and Scripting

compare two txt files

i have two files file1 ----- absgsh jshsh shshhs hshhs file2 ------ kakkaka iurir brbrbrbr rjrbjrhjkehr rgjhergrhg hrghrgh jrhgrjg i want bash shell script to campare line1-file1 - line-file2 line2-file1 -line2 file2 ........ ( without diff , cmp , comm ) thanks... (8 Replies)
Discussion started by: space13
8 Replies
Login or Register to Ask a Question