Hey. I'm just getting started with scripting and although i will admit i haven't searched the forum yet, i think it would be a waste of time. It really will be very simple.
I want to enter a list of arguments after my script with the last being the filename. (not the first, as this is part of the requirements)
I so far have
Now i have put every variation i can think of around the second lines var in order the change the value of filename to be from the location in the list of arguments to the argument itself, ie if i put
sh script hi there smelly
smelly is the last argument.
i want the filename to take on the value of the file smelly, not the value 3 (3rd argument)
if i put sh script hi there scriptfile1
where scriptfile1 exists and is the file i want to to point to, it still has argument 3. Whilst I would rather have it point to a file that already exists, i don't mind if it creates a new tempfile, (and will do checks on if files exist once i can get this sorted) i would just like to know how i can have it point to a filename rather than the argument number.
I'm sure i've made that a lot more difficult that it is, but any advice would be appreciated.
in vi, if i type ctrl-J, i can shift the next line up to the current line.
I need to do this whenever a specific string exists (in particular ^M) ,however i have not been able to find a way to do this in vi, sed, or awk
seems simple enough.
can someone help me?
thanks in advance (9 Replies)
I have a ascii file with lines like this:
240|^M\ ^M\^M\ Old Port Marketing order recd $62,664.- to ship 6/22/99^M\
when this record gets loaded into my database, the \ is stored literally and so the user sees carriage return \ (hex 0D 5C) when what i need is carriage return line feed (hex 0D... (1 Reply)
Hi
I need to define a pattern that will match an open square bracket, a series of numbers fro 1 to 4 digits in length and a close square bracket. Examples of the numbers I will need to find are:
or
or
or
I am using BBEdit to search, and BBEdit uses the standard GREP search... (1 Reply)
hi there,
I am a complete newb to bash but am going to try and make a script to help me seach text files for strings of interest, any help that one of you gurus could pass on will be greatly received!!
I want to write something like:
in "text1.txt" find "string1" and copy out the line... (7 Replies)
Hello
I am trying to do global search on access log files for a date and for either 'Error|error' string
ls -lrt *access* | grep "Sep 23" | awk '{print $9}'|xargs awk '/23\/Sep\/2011/ && /Error/ || /error'
Above matches All lines with 'error' as well unfortunately.
Is there a... (6 Replies)
Hello;
we have :
awk '/reg_exp/,0/
prints every line after the first occurrence of "reg_exp"
But if I want to print rest of the lines AFTER the last occurrence of "reg_exp",
how would I do it ??
Tried :
awk ' ! (/reg_exp/,0)'
But it errored...
Thank you for any... (5 Replies)
Hello all!
This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician.
Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix:
... (16 Replies)
Cheers!
In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not?
To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
I have a text file (allWords.txt), that I would like to search through. Here is a snippet of what it looks like...
a
aah
aahed
aahing
aahs
aardvark
aardvarks
aardwolf
ab
abaci
aback
abacus
abacuses
abaft
......
I would like to use the grep search to search, line by line, for... (8 Replies)
Discussion started by: blackvelvet
8 Replies
LEARN ABOUT REDHAT
fileutil
fileutil(n) file utilities fileutil(n)
NAME
fileutil - Procedures implementing some file utilities
SYNOPSIS
package require Tcl 8
package require fileutil ?1.4?
::fileutil::cat filename
::fileutil::fileType filename
::fileutil::find ?basedir ?filtercmd??
::fileutil::findByPattern basedir ?-regexp|-glob? ?--? patterns
::fileutil::foreachLine var filename cmd
::fileutil::grep pattern ?files?
::fileutil::stripN path n
::fileutil::stripPwd path
::fileutil::touch ?-a? ?-c? ?-m? ?-r ref_file? ?-t time? filename ?...?
DESCRIPTION
This package provides implementations of standard unix utilities.
::fileutil::cat filename
A tcl implementation of the UNIX cat command. Returns the contents of the specified file. The first argument is the name of the
file to read.
::fileutil::fileType filename
An implementation of the UNIX file command, which uses various heuristics to guess the type of a file. Returns a list specifying as
much type information as can be determined about the file, from most general (eg, "binary" or "text") to most specific (eg, "gif").
For example, the return value for a GIF file would be "binary graphic gif". The command will detect the following types of files:
directory, empty, binary, text, script (with interpreter), executable elf, graphic gif, graphic jpeg, html, xml (with doctype if
available), message pgp, and link.
::fileutil::find ?basedir ?filtercmd??
An implementation of the unix command find. Adapted from the Tcler's Wiki. Takes at most two arguments, the path to the directory to
start searching from and a command to use to evaluate interest in each file. The path defaults to ".", i.e. the current directory.
The command defaults to the empty string, which means that all files are of interest. The command takes care not to loose itself in
infinite loops upon encountering circular link structures. The result of the command is a list containing the paths to the inter-
esting files.
::fileutil::findByPattern basedir ?-regexp|-glob? ?--? patterns
This command is based upon the TclX command recursive_glob, except that it doesn't allow recursion over more than one directory at a
time. It uses ::fileutil::find internally and is thus able to and does follow symbolic links, something the TclX command does not
do. First argument is the directory to start the search in, second argument is a list of patterns. The command returns a list of all
files reachable through basedir whose names match at least one of the patterns. The options before the pattern-list determine the
style of matching, either regexp or glob. glob-style matching is the default if no options are given. Usage of the option -- stops
option processing. This allows the use of a leading '-' in the patterns.
::fileutil::foreachLine var filename cmd
The command reads the file filename and executes the script cmd for every line in the file. During the execution of the script the
variable var is set to the contents of the current line. The return value of this command is the result of the last invocation of
the script cmd or the empty string if the file was empty.
::fileutil::grep pattern ?files?
Implementation of grep. Adapted from the Tcler's Wiki. The first argument defines the pattern to search for. This is followed by a
list of files to search through. The list is optional and stdin will be used if it is missing. The result of the procedures is a
list containing the matches. Each match is a single element of the list and contains filename, number and contents of the matching
line, separated by a colons.
::fileutil::stripN path n
Removes the first n elements from the specified path and returns the modified path. If n is greater than the number of components in
path an empty string is returned.
::fileutil::stripPwd path
If the path is inside of the directory returned by [pwd] it is made relative to that directory. In other words, the current working
directory is stripped from the path. The possibly modified path is returned as the result of the command.
::fileutil::touch ?-a? ?-c? ?-m? ?-r ref_file? ?-t time? filename ?...?
Implementation of touch. Alter the atime and mtime of the specified files. If -c, do not create files if they do not already exist.
If -r, use the atime and mtime from ref_file. If -t, use the integer clock value time. It is illegal to specify both -r and -t. If
-a, only change the atime. If -m, only change the mtime.
KEYWORDS
file utilities
fileutil 1.4 fileutil(n)