Sponsored Content
Top Forums Shell Programming and Scripting Delete all files if another files in the same directory has a matching occurence of a specific word Post 302373189 by premier_de on Thursday 19th of November 2009 04:49:16 PM
Old 11-19-2009
Delete all files if another files in the same directory has a matching occurence of a specific word

Hello,
I have several files in a specific directory.
A specific string in one file can occur in another files.
If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string.

Example.
file1
ShortName "Blue Jeans"
price 89.47
cur EURO
file2
ShortName "Blue Jeans"
Price 59.47
CUR USD
file3
ShortName "Blue Jeans"
Price 99.47
CUR GBP
Since the value of ShortName "Blue Jeans" is occuring in file2 & file3. Both this file should be deleted. Similarly files with other ShortName
Could any one please help me how can it done via script (ksh, SED, AWK). I am on solaris.

Thank you
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete files in specific directory

i have a directory "ABC" with lots of old files and sub directories in it. the issue now is i want to delete away files which are older than 15 days in "ABC" without deleting the files in the sub directories and without deleting the sub directory. i tried using find command but it will drill down... (2 Replies)
Discussion started by: legato
2 Replies

2. Shell Programming and Scripting

Delete all occurence of a word in one shot

i have a file called file1 cat file1 i am namish namish lives in India India and namish both are good. I want to delete all the occurences of namish in one shot,if i do it with sed i guess all the lines will be deleted containing the pattern.Suggest me any idea without AWK. Thanks... (6 Replies)
Discussion started by: namishtiwari
6 Replies

3. Shell Programming and Scripting

Find and replace a word in all the files (that contain the word) under a directory

Hi Everyone, I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap". For Example: In the Directory, $pwd /home/nick $ grep -l "xsgd1234dap" *.sh | wc -l 119 I have "119" files that are still using... (5 Replies)
Discussion started by: filter
5 Replies

4. UNIX for Dummies Questions & Answers

List all files with sum of matching word

grep -c 'avihai' 1.log will give me count of 'avihai' in log I want to have a list of files in the folder that show file name with count side by side. Please advice (2 Replies)
Discussion started by: avihaimar
2 Replies

5. Shell Programming and Scripting

How to delete last occurence of word using Linux command?

Hi all, I am trying to delete last occurrence of word using sed command. for example. I have input like this on a.id1 = b.id1 and on a.id2 = b.id2 and on a.id3 = b.id3 and and I am expecting output like this on a.id1 = b.id1 and on a.id2 = b.id2 and on a.id3 = b.id3 I just need to... (11 Replies)
Discussion started by: nsk
11 Replies

6. Shell Programming and Scripting

Delete all files with specific extension in directory tree

I'm sure this has been asked many times, but a search didn't turn up a definitive best method for this (if there ever is such a thing). I have been using rsync to back up my main data directory, but I have accumulated a large number of older backups that I don't need. All of the files I don't... (14 Replies)
Discussion started by: LMHmedchem
14 Replies

7. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurrence of a specific word

he following are the files available in my directory RSK_123_20141113_031500.txt RSK_123_20141113_081500.txt RSK_126_20141113_041500.txt RSK_126_20141113_081800.txt RSK_128_20141113_091600.txt Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Discussion started by: kridhick
7 Replies

8. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

9. Shell Programming and Scripting

How to delete all the files and folders inside all the directories except some specific directory?

hi, i have a requirement to delete all the files from all the directories except some specific directories like archive and log. for example: there are following directories such as A B C D Archive E Log F which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
Discussion started by: Little
7 Replies
config(8)						      System Manager's Manual							 config(8)

NAME
config - Builds system configuration files SYNOPSIS
/sys/conf/config [-k] [-p] [-q] system_name FLAGS
Creates a define variable 'KDEBUG' that can be used to conditionally compile source code for kernel debugging. Configure the system for profiling. You must have sources to use this flag. Concatenates and displays all the system configuration files, including any configura- tion files described in the /sys/conf/NAME.list file. DESCRIPTION
The doconfig command calls the config command to build a set of system configuration files from a file that describes the sort of system that is being configured. The config command also takes as input another file that tells it what files are needed to generate a system. This other file can be augmented by a configuration-specific set of files that name alternate files for a specific machine. Normally, you should run the doconfig program and not the config command. If you need to issue the config command, be sure to change your directory to the /sys/conf directory. As an argument to the config command, specify the name of a system configuration file containing device specifications, configuration options and other system parameters for that specific system configuration. The config command places all its output files in the directory The output of config consists of a number of files; each machine type has its own specific set of files. All machine types have a makefile which is used by make during the system build. Typically, there are also a set of header files which contain definitions of the number of various devices that will be compiled into the system, and a set of swap configuration files contain definitions for the disk areas to be used for swapping, the root file system, argument processing, and system dumps. After running config, you run make depend in the directory where the new makefile was created. If any other error messages are produced by config, the problems in the configuration file should be corrected and config should be run again. Attempts to compile a system that had configuration errors are likely to be unsuccessful. NOTES
The line numbers reported in error messages are usually off by one. FILES
List of common files used to build the system List of files specific to NAME, where NAME is the value specified for the ident option in the system configuration file Machine-independent portion of the makefile template used for building kernels from binaries Machine-independent portion of the makefile template used for building kernels from sources Machine-dependent portion of the makefile template List of machine- specific files Machine-specific name to major device mapping file RELATED INFORMATION
Commands: make(1), doconfig(8) System Administration delim off config(8)
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy