Sponsored Content
Top Forums Shell Programming and Scripting Finding a text in files & replacing it with unique strings Post 302761533 by spacebar on Friday 25th of January 2013 09:20:08 PM
Old 01-25-2013
Try it like this:
Code:
while read rec
do
  file=`echo $rec | cut -d ";" -f1`
  pattern1=`echo $rec | cut -d ";" -f2`
  pattern2=`echo $rec | cut -d ";" -f3`
  sed -i "s/${pattern1}/${pattern2}/" $file
done <file.csv

 

10 More Discussions You Might Find Interesting

1. Solaris

finding & replacing blank rows/spaces in a file

Can anyone help me find and replace blank rows in a file with a numeric value (ie blankrow=someTxtOrNumValue), the file is over 500,000 rows long so it would need to be the quickest way as I'll need to do this for multiple files...I would be greatfull for any suggestions....thanks sample file:... (2 Replies)
Discussion started by: Gerry405
2 Replies

2. Shell Programming and Scripting

replacing strings with text from other file

Hi, Im trying to update some properties files with text from another file: file1 user=xyz file2 user= after script file2 user=xyz Im using this reading the $QUARTZURL,ETC... from quartz.properties: echo... (1 Reply)
Discussion started by: mc1392
1 Replies

3. Shell Programming and Scripting

help with finding & replacing pattern in a file

Hi everyone. Could u be so kind and help me with on "simple" shell script? 1. i need to search a file line by line for a pattern. example of a lines in that file 2947 domain = feD,id = 00 0A 02 48 17 1E 1D 39 DE 00 0E 00,Name Values:snNo = f10 Add AttFlag = 0 2. i need to find... (0 Replies)
Discussion started by: dusoo
0 Replies

4. UNIX for Dummies Questions & Answers

Finding & Replacing specific Fields

All I have a very large file (aproximately 150,000) as shown below separated by pipe "|". I need to replace data in 2, 16, 17, 23 fields that are of time stamp format. My goal is to look in those fields and it ends with "000000|" then replace it with "000|". In other words, make it as 6 digit... (2 Replies)
Discussion started by: ddraj2015
2 Replies

5. UNIX for Dummies Questions & Answers

Finding Unique strings which match pattern

I need to grep for a pattern in a file. Files are huge and have several repeated occurances of the strings which match pattern. I just need the strings which contain the pattern in the output. For eg. The contents of my file are as follows. The pattern I want to match by is ABCD ... (5 Replies)
Discussion started by: tektips
5 Replies

6. Homework & Coursework Questions

Finding/replacing text and redirection help

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: What command would rename "sequentialInsert", in ~cs252/Assignments/commandsAsst/project/arrayops.h, to... (2 Replies)
Discussion started by: lothwen
2 Replies

7. Shell Programming and Scripting

Replacing variable Text between fixed strings

Hello all, This is my first post and I hope you can help me out. I searched for quite some hours now and haven't found a simple solution to my problem. It is as following: I got this file: dl.dropbox.com/u/14586156/stuff/Bookmarks.plist and want to replace the Text between... (9 Replies)
Discussion started by: pasc
9 Replies

8. Shell Programming and Scripting

Extended replacing of nonspecific strings in text files [beware complicated !]

Well, to make another post at this helpful forum :b::D: I recently tried something like this, I want to replace all those numberings/letters that are located between <string>file://localhost/var/mobile/Applications/ and /Documents/</string> numberings =---- replace with: first... (6 Replies)
Discussion started by: pasc
6 Replies

9. Shell Programming and Scripting

Finding/replacing strings in some files based on a file

Hi, We have a file (e.g. a .csv file, but could be any other format), with 2 columns: the old value and the new value. We need to modify all the files within the current directory (including subdirectories), so find and replace the contents found in the first column within the file, with the... (9 Replies)
Discussion started by: Talkabout
9 Replies

10. Shell Programming and Scripting

Command to show unique strings in two files

how to display the unique strings in two files using shell script or commands. I tried diff and cmp but it shows the entire line, i need only the mismatched strings. File1: sat,sun,mon,tue rose,lilly,lotus white,red,blue,green,pink File2: sat,sun,mon,tue rose,sunflower,lotus... (4 Replies)
Discussion started by: Arun_Linux
4 Replies
MIXER(8)						    BSD System Manager's Manual 						  MIXER(8)

NAME
mixer -- set/display soundcard mixer values SYNOPSIS
mixer [-f device] [-s | -S] [dev [[+|-]lvol[:[+|-]rvol]]] ... mixer [-f device] [-s | -S] recsrc ... mixer [-f device] [-s | -S] {^|+|-|=}rec rdev ... DESCRIPTION
The mixer utility is used to set and display soundcard mixer device levels. It may also be used to start and stop recording from the sound- card. The list of mixer devices that may be modified are: vol, bass, treble, synth, pcm, speaker, line, mic, cd, mix, pcm2, rec, igain, ogain, line1, line2, line3, dig1, dig2, dig3, phin, phout, video, radio, and monitor. Not all mixer devices are available. Without any arguments, mixer displays the current settings for all supported devices, followed by information about the current recording input devices. If the dev argument is specified, mixer displays only the value for that dev. To modify the mixer value dev, the optional left and right channel settings of lvol[:rvol] may be specified. The lvol and rvol arguments may be from 0 - 100. Omitting dev and including only the channel settings will change the main volume level. If the left or right channel settings are prefixed with + or -, the value following will be used as a relative adjustment, modifying the cur- rent settings by the amount specified. If the -s flag is used, the current mixer values will be displayed in a format suitable for use as the command-line arguments to a future invocation of mixer (as above). The -S flag provides the above output without mixing field separators. To change the recording device you use one of: ^rec toggles rdev of possible recording devices +rec adds rdev to possible recording devices -rec removes rdev from possible recording devices =rec sets the recording device to rdev The above commands work on an internal mask. After all the options have been parsed, it will set then read the mask from the sound card. This will let you see EXACTLY what the soundcard is using for the recording device(s). The option recsrc will display the current recording devices. The option -f device will open device as the mixer device. FILES
/dev/mixer the default mixer device SEE ALSO
cdcontrol(1), sound(4) HISTORY
The mixer utility first appeared in FreeBSD 2.0.5. AUTHORS
Original source by Craig Metz <cmetz@thor.tjhsst.edu> and Hannu Savolainen. Mostly rewritten by John-Mark Gurney <jmg@FreeBSD.org>. This manual page was written by Mike Pritchard <mpp@FreeBSD.org>. BSD
June 2, 2014 BSD
All times are GMT -4. The time now is 07:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy