08-09-2015
UNIX Scripting help to input string and search a file to find
Hi everyone,
I am new to Unix and need help writing a script that can ask user for an input, then search that input within a file
I know will have to use the read and grep commands, anyone can give me somewhere to start would help
Task: Write a script to display which volume pool a given tape belongs. This script should use as input a file that contains a list of tape barcodes.
thanks,
Richard
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi
i need to print pathname in which the string present using 'find' command
sample output like this
Pathname String to be searched
---------- --------------------
/usr/test/myfile get
/opt/test/somefile get
Thanks in... (4 Replies)
Discussion started by: princein
4 Replies
2. UNIX for Dummies Questions & Answers
Guys - I am new to Unix scripting and am in need for a script that does the following. I have bits and pieces created and tested but i am just having a little difficult time getting it all together.
- Loop through till it finds a string in a specific file.
Any help is greatly appreciated.
... (1 Reply)
Discussion started by: mrehman
1 Replies
3. UNIX for Dummies Questions & Answers
ALL,
My shell script takes a employee file as input.
I have to identify the list of employees not in the input file and update their status in the database.
Approach I followed:
by traversing through the input file add all the emplid's to a variable.
update the status of employees not in... (2 Replies)
Discussion started by: sailussr
2 Replies
4. Shell Programming and Scripting
Hi I want to search the following in the entire file and put them in a diff file.
file 1 contains :
Non error probabilities are not decreasing in curve 1GEORGE_SGD_SUB
Mid Point RESCAP_SGD_SNU curve have errors
Non default probabilities are not decreasing in curve ABF_JPY_SUB
Mid Point... (3 Replies)
Discussion started by: szchmaltz
3 Replies
5. Shell Programming and Scripting
Hi,
I have the output (as below) which i want it to be in a table.
For e.g.
space utilization in PSE on path /logs is 0%
space utilization in PSE on path /logs/tuxedo/tuxlsp is 16%
space utilization in PSE on path /ldvarlsp/lsp/log is 37%
space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies
6. Shell Programming and Scripting
Hi ,
I have a file myhost.txt which contains below,
127.0.0.1 localhost
1.17.1.5 atrpx958
11.17.10.11 atrpx958zone nsybhost
I need to append words only after "atrpx958" like 'myhost' and 'libhost' and not after atrpx958zone.
How to search the word atrpx958(which is hostname) only,... (5 Replies)
Discussion started by: gsreeni
5 Replies
7. Shell Programming and Scripting
Hi everyone,
I am new to Unix and need help writing a script that can ask user for an input, then search that input within a file
I know will have to use the read and grep commands, anyone can give me somewhere to start would help
Task: Write a script to display which volume pool a given... (1 Reply)
Discussion started by: 12ic11
1 Replies
8. Shell Programming and Scripting
Hi Don, this is not homework question. I work for a Credit card company and my development goal this year is to learn Unix. I would love if others can help me get started, thanks.
Hi everyone
I am new to Unix and need help writing a script that can ask user for an input, then search that input... (2 Replies)
Discussion started by: 12ic11
2 Replies
9. Shell Programming and Scripting
Hi,
How can I use find command to search string/pattern in a file recursively?
What I tried:
find . -type f -exec cat {} | grep "make" \;
Output:
grep: find: ;: No such file or directory
missing argument to `-exec'
And this:
find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
Discussion started by: cola
12 Replies
10. UNIX for Beginners Questions & Answers
I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this.
string(Scenario 1)- user::r--,user::ourfrd:r--
String(Scenario 2)- user::r--
File
****
# file: /local/Desktop/myfile
# owner: me
# group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
CG(1) CG(1)
NAME
cg - Recursively grep for a pattern and store it.
SYNOPSIS
cg [ -l ] | [ [ -i ] pattern [ files ] ]
DESCRIPTION
cg does a search though text files (usually source code) recursively for a pattern, storing matches and displaying the output in a human-
readable fashion. It is intended to give some of the functionaly of AT&T's cscope(1) tool, with the advantages of simplicity and not being
language-specific. The script will colorize output if configured as such.
It is typically run with a Perl regular expression to search for. The search can be made case insensitive by using the -i option. A list
of files may also be specified with an additional argument after the pattern. Put the files pattern in quotes to make it be matched by
Perl rather than by the shell. Running the script with no arguments will recall the results of the previous search. After the search,
entries found can be edited using the vg(1) script. The -l option shows the last log made.
SOME EXAMPLES
cg - alone recalls the previous search results.
cg -i pattern - search the default list of files for all files matching the pattern (and case-insensitively).
cg pattern '*.c' - search recursively for pattern in all *.c files. This automatically converts '*' to '.*' and '.' to '.' for you and
does a Perl pattern match on all files in the tree.
cg pattern *.c - search through the shell-expanded list of *.c files, so not done recursively (in other words, only the files your shell
pass to the script as arguments).
cg -l - show the last log made.
COMMAND-LINE OPTIONS
-i Do a case-insensitive search.
-l Show the last log made.
-p Toggle the default pager option. cg has a bulit-in pager function, which can be enabled or disabled by default (in .cgvgrc). If the
default is enabled, this option disables the pager; if the default is disabled, this option enables it.
-P Force the built-in pager to be disabled.
FILES
${HOME}/.cglast
Log file of the last search.
${HOME}/.cgvgrc
Per-user configuration file (if the defaults are not desireable).
${HOME}/.cgvg/*
Log files in $HOSTNAME.shell_pid form with the log of the last search.
SEE ALSO
vg(1), perl(1), find(1), grep(1), cscope(1)
AUTHOR
cg was written by Joshua Uziel <uzi@uzix.org>.
13 Mar 2002 CG(1)