G. ASCII/TEXT FILES
Very frequently you have to work with text files while digging inside the hard disks of your stations. At those times you have to be careful in not trying to cat/more a file that is not of the ascii type, or you will end up hanging your WYSE/telnet session.
These simple scripts help me at those times.
G1. GET TEXT FILES LIST
As ascii files we can consider all files detected as: ascii, command, and text files. The script "text" produces a list of all these types of files in the current directory. The output list can be used for other purposes like: more, delete, etc.
Whenever you are in an strange directory, just type
/opt/ac/listto see which files you can observe safely.
G2. GET NON-TEXT FILES LIST
The script "nontext" will give you the opposite of the previous script: the list of all non ascii/command/text files. Use it for similar purposes.
G3. GET ALL TEXT FILES
I wrote this script "get_text" to grab ALL ascii/command/text files from any directory, and put them into one single file. The output file will have also the station name, date, and the list of files currently captured.
I use this script any time I want to gather all the information available in certain directory. It might be for example Sequence blocks code, configuration files (IIF,etc), scripts, etc, etc. To use it, go to the desired directory and enter: /opt/ac/get_text. When it finished, the output file will be waiting for you as: /opt/ac/text.txt.
The script will start asking if you want the files in current directory only, or if you want to include all files in the subdirectories below (recursive). After that, it will search all files and select the ones that are of the ascii/command/text type.
Next, the script will ask you if you want to know the size of the output file. After that, it will ask you to confirm that you really want to create the output file. If you say yes, the output file is created.
The output file is always named: /opt/ac/text.txt . You should rename it with the directory name from which it was created, or any other name you want. Just don't forget to rename it or it will be overwritten the next time you run the script.
You can modify the file /opt/ac/text.lst and delete the filenames of the ones you are not interested on. The next time you run the script, it will find the old text.lst and it will ask you if you want to use it. If you say no, it will delete that file and create a new one.
G4. GREPPY
The need for "greppy" came whenever I needed to search for an string (variable name) in a bunch of files in certain directory.
To prevent searching on binary files, "greppy" will first find the 'readable' (ascii) files, and then it will use egrep to find which files contain the desired string.
To use it, go to desired directory and type: /opt/ac/greppy xxxxx ,where xxxxx is the string to search for.
This page hosted by
Get your own Free Home Page