Sponsored Content
Top Forums Shell Programming and Scripting [SOLVED] Replace a string in nextline after searching a pattern Post 302699895 by msabhi on Wednesday 12th of September 2012 01:46:41 PM
Old 09-12-2012
Code:
 awk '/ID</{print;getline;if(/@%/){sub(/ID_Value/,"CHANGE HERE");}} !/ID</' input_file

Whatever you wanna change just change in the text "CHANGE HERE".
This User Gave Thanks to msabhi For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Searching for files with certain string pattern

Hello All I would like to search for files containing certain string pattern under all the directories under /vobs/vobname and print the output to a file in my home directory. How can I do this? Note: /vobs/vobname conatins several directories. Thank You in advance newbetounix (1 Reply)
Discussion started by: intrigue
1 Replies

2. Shell Programming and Scripting

Match pattern and replace with string

hi guys, insert into /*<new>*/abc_db.tbl_name this is should be replaced to insert into /*<new>*/${new}.tbl_name it should use '.' as delimiter and replace is there any way to do it using sed (6 Replies)
Discussion started by: sol_nov
6 Replies

3. Shell Programming and Scripting

Pattern searching and replace

I have data this data in a text file 1 PSE480 (P) 2 PSE600 (P) 3 (P) PSE600 4 (P) PSE720 5 PSE600 (P) 6 PSE720 (P) 7 x12(P)PSE360 8 PSE450 (P) 9 PSE540 (P) 10 PSE720 (P) 11 (P) PSE1440 12 24sPSE720 (P) What i want id the last 3 (or 4 in one case) characters after PSE my final... (2 Replies)
Discussion started by: lifzgud
2 Replies

4. Shell Programming and Scripting

Searching String from set of similar File pattern from the Dir

Guys, Here is the script that searches string from the set of similar files from the log directory, All the file patterns are defined as input file, from where the script should map to those files in the LOG_DIR and should start searching the strings from all those similar files. ... (1 Reply)
Discussion started by: raghunsi
1 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. Shell Programming and Scripting

Searching a particular string pattern in 10000 files

Problem Statement:- I need to search a particular `String Pattern` in around `10000 files` and find the records which contains that `particular pattern`. I can use `grep` here, but it is taking lots of time. Below is the command I am using to search a `particular string pattern` after... (3 Replies)
Discussion started by: raihan26
3 Replies

7. Shell Programming and Scripting

Replace a string pattern

Hi, I have a CSV with following type of data and would like to replace the timestamp information with 'null' string. Can you please suggest me on same? 8,1,'1','1',11,'2013-08-12 18:34:17.0','null',1,'2013-08-12 18:34:17.0','null','PROMOTIONAL','12','1','11','11',11,'0' Thanks for your... (10 Replies)
Discussion started by: bhupinder08
10 Replies

8. Shell Programming and Scripting

Replace string in line below specific pattern?

Hi, I'm trying to replace a string with sed, in a text file containing this pattern: location alpha value x location beta value y location gamma value y location delta value y location theta value z ... What I want to achieve is: Find location beta into text file... (1 Reply)
Discussion started by: TECK
1 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Replace the second pattern alone in VI.

I have lines like: table10 table_name_10 table10 table_name_10 table20 table_name_20 table20 table_name_20 table30 table_name_30 table30 table_name_30 I want to change the second "table_names" in all lines to test_table_name. Required output would be: table10 table_name_10 table10... (19 Replies)
Discussion started by: gctex
19 Replies

10. Shell Programming and Scripting

Replace string - searching from input file

Hi I need help with writing a script to change a string in a file. The script needs to read an input list (list.txt) file line by line searching for that string in a text.file. Once the string is found the last few words in the string should be replaced. eg list.txt will contain hello my... (6 Replies)
Discussion started by: sudobash
6 Replies
APT-FILE(1)															       APT-FILE(1)

NAME
apt-file - APT package searching utility -- command-line interface SYNOPSIS
apt-file [ options ] [ action ] [ pattern ] apt-file -f [ options ] search [ file ... ] apt-file -D [ options ] search [ binary-packet.deb ... ] DESCRIPTION
apt-file is a command line tool for searching files in packages for the APT package management system. Some actions are required to run the search: find Alias for search. list List the contents of a package matching the pattern pattern. This action is very close to the dpkg -L command except the package does not need to be installed or fetched. purge remove all Contents-* files from the cache directory. search Search in which package a file is included. A list of all packages containing the pattern pattern is returned. apt-file will only search for filenames, not directory names. This is due to the format of the Contents files it searches. show Alias for list. update Resynchronize the package contents from their sources. The lists of the contents of packages are fetched from the location(s) speci- fied in /etc/apt/sources.list. This command attempts to fetch the Contents-<ARCH>.gz files from remote sources. For downloading these uses either the curl or wget commands as specified in apt-file.conf. OPTIONS
-a, --architecture architecture Sets architecture to architecture. This option is useful if you search a package for a different architecture from the one installed on your system. It determines how the $ARCH variable in sources.list is expanded (but it does not influence the search in any other way). -c, --cache cache-directory Sets the cache directory to cache-directory instead of its default. If executed as non-root user, the default is $HOME/.cache/apt- file with fall-back to /var/cache/apt/apt-file. The latter is also the default if apt-file is called as root. -d, --cdrom-mount cdrom-mount-point Use cdrom-mount-point instead of apt's. -D, --from-deb Use contents of the given .deb archives(s) as patterns. Useful for searching for file conflicts with other packages. Implies -F. -f, --from-file Read patterns from the given file(s), one per line. Use -f - for stdin. This is much faster than invoking apt-file many times. -F, --fixed-string Do not expand search pattern with generic characters at pattern's start and end. -i, --ignore-case Ignore case when searching for pattern. -l, --package-only Only display package name; do not display file names. -N, --non-interactive Skip schemes that are listed in the interactive line in apt-file.conf. This is useful if you want to call 'apt-file update' in cron jobs and skip all schemes that may require user input. -s, --sources-list sources.list Sets the sources.list file to a different value from its default /etc/apt/sources.list. -v, --verbose Run apt-file in verbose mode. -x, --regexp Treat pattern as a (perl) regular expression. See perlreref(1) for details. Without this option, pattern is treated as a literal string to search for. -y, --dummy Run in dummy mode (no action). -h, --help Display a short help screen. CONFIGURATION FILE
The apt-file configuration file can be found in /etc/apt/apt-file.conf. A string expansion is done on several values. See the string expansion section. destination This variable describes how cached files will be named. http | ftp | ssh | rsh | file | cdrom Defines the commands used to fetch files. STRING EXPANSION A sources.list entry is defined as: deb uri dist component1 component2 ... A uri is defined as: proto:/[/][user[:password]@]host[:port][/path] <host> replace with the hostname <port> replace with the port number <uri> replace with full uri <path> replace with full path (relative to / on the host) <dist> replace with distribution name <comp> replace with component name <cache> replace with cache directory <dest> replace with destination expanded value. <cdrom> replace with cdrom-mount-point. BUGS
The cdrom backend has not been tested. Non-release lines in sources.list are not handled by apt-file. There is only one Contents file per distribution that contains all components (i.e. main, contrib, and non-free). Threrefore, apt-file will display search results from all components, even if not all components are included in the sources.list file. When a new line has been added to the sources.list and apt-file update has not been run, apt-file does not print a warning message. Complex regular expressions that match the leading slash may not work correctly. As a workaround, try to pull the leading slash to the beginning of the regular expression. For example, use "/(usr/bin/vim|sbin/lvm)" instead of "/usr/bin/vim|/sbin/lvm". FILES
/etc/apt/sources.list Locations to fetch package contents from. /etc/apt/sources.list.d/ Directory with additional sources.list snippets /etc/apt/apt-file.conf Configuration file for apt-file. SEE ALSO
auto-apt(1), apt-cache(8), apt-cdrom(8), dpkg(8), dselect(8), sources.list(5), apt.conf(5), apt_preferences(5). The APT users guide in /usr/share/doc/apt/ AUTHOR
apt-file was written by Sebastien J. Gross <sjg@debian.org>. May 2003 APT-FILE(1)
All times are GMT -4. The time now is 08:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy