Sponsored Content
Top Forums Shell Programming and Scripting Conditional search and delete using SED / Shell script Post 302583201 by dominiclajs on Tuesday 20th of December 2011 12:40:00 AM
Old 12-20-2011
Conditional search and delete using SED / Shell script

Hi,
I want to perform a conditional search and remove my search string.

Input string: "abcdaabcadgfaarstab"
Character to search: "a"
Condition: Remove all "a" in the input string except if it is "aa"
Output string: "bcdaabcdgfaarstb"

Can you please help me in this?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to search a string and delete the content

Hi, I've a shell script e.g. #!/bin/bash echo "Enter the next hop id" read nhid echo "enter the IP address" read IP echo "enter the interface name" read name echo "enter the enable/disable state" read state exit 0 now from this script i want to search strings in another (.cam) ... (6 Replies)
Discussion started by: vic_mnnit
6 Replies

2. Shell Programming and Scripting

Help with search and delete/add/modify script

Gurus, I need to run a script on multiple XML files in different directories and do the following (the output can be redirected to create a new file) 1. Search a pattern like "abc.mno.xyz" in an XML file, once detected, the script should delete one line above and 3 lines below (including the... (2 Replies)
Discussion started by: inditopgun
2 Replies

3. Shell Programming and Scripting

Help on shell script conditional execution when CPU Idle > 60%

I need a shell script that will monitor a few conditions and not execute until the these conditions are met. The problem I'm having is that I can not perform a database snapshot (backup) of a sybaseIQ database unless the CPU Status Idle % is above 60% or the snapshot (backup) fails. If... (2 Replies)
Discussion started by: pancona99
2 Replies

4. Shell Programming and Scripting

search and conditional execution

Hi, I have a list of files with different filenames like nam0001.txt,pan0001.txt etc coming in /data/inbox from various places. I needed a shell script which would:- 1)searches for a word from the filenames (coming in inbox directory) provided in input parameter. 2)if found, put in... (2 Replies)
Discussion started by: Saiesh
2 Replies

5. Shell Programming and Scripting

sed search pattern and delete lines

Hello, i have a question. My problem is that i have a file like: TEST JOHN ADAM MICHAEL SEBASTIAN ANDY i want find for MICHAEL and want delete lines like this: TEST (4 Replies)
Discussion started by: eightball
4 Replies

6. Shell Programming and Scripting

Conditional Search/Replace

I'm looking for an awk or (preferably) sed solution to search a pipe delimited file for any occurrence of an email address that does not include a designed domain, and replace the email address with a blank. E.g. hello|smith@designateddomain.com|jones@anotherdomain.edu|1234| turns into: ... (2 Replies)
Discussion started by: tiggyboo
2 Replies

7. Homework & Coursework Questions

sed Multiple Pattern search and delete the line

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have file which has got the following content sam 123 LD 41 sam 234 kp sam LD 41 kam pu sam LD 61 Now... (1 Reply)
Discussion started by: muchyog
1 Replies

8. Shell Programming and Scripting

Conditional string search

Hi, I need to search/grep userid and its value based on a condition that the user id is under the heading "*central_test*" in a big file of about 70808MB. The * represents some strings before and after the string "centrla_test". Could anyone please guide. OS is hp-ux. (2 Replies)
Discussion started by: sam_bd
2 Replies

9. Shell Programming and Scripting

Conditional delete

Hi Friends, I have somefiles like 20180720_1812.tar.gz 20180720_1912.tar.gz 20180720_2012.tar.gz 20180720_2112.tar.gz 20180721_0012.tar.gz 20180721_0112.tar.gz 20180721_0212.tar.gz 20180721_0312.tar.gz in a directory and so on..these files gets created every 3 hours where as... (28 Replies)
Discussion started by: onenessboy
28 Replies

10. Shell Programming and Scripting

Conditional delete -- New glitch

Hi Please dont consider this as duplicated post.. I am using below pattern to find delete files to bringdown disc size.. however how i can make sure ist going to correct folder and searching for files... while print "echo rm " LastFile correctly print files names for deletion, but when i... (7 Replies)
Discussion started by: onenessboy
7 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)
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy