Sponsored Content
Top Forums Shell Programming and Scripting How to apply a regular expression in all the files in a directory Post 302367168 by Lucky Ali on Sunday 1st of November 2009 04:17:50 PM
Old 11-01-2009
How to apply a regular expression in all the files in a directory

I have say 100 text files (with .txt extension) in a directory.
An example of the content in the file is given below

"NAME"
"cgd1_200"
"cgd1_3210"
"cgd1_560"
"cgd2_2760"
"cgd2_290"
"cgd3_3210"
"cgd3_3310"
"cgd3_660"
"cgd5_2130"
"cgd5_4080"
"cgd6_3690"
"cgd6_4480"
"cgd8_1540"
"cgd8_3860

I wanted to remove the " " from the above file in all the lines.
I can apply regular expression to this file using the command %s/"//ig.
But I have to do it for each and every file.

How do i apply the above regular expression in awk or shell programming so that I do it to all the files in the directory at once.

Please let me know.

Please let me know.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Let GID apply to new files in directory

Hi, Does anyone know if it is possible to override the GID which files have when they are created in a specific folder? I want the given GID for the folder to apply to the new files created in the folder, no matter what group the owner of the files have... I have tried sticky bits but doesn't... (1 Reply)
Discussion started by: linge
1 Replies

2. Shell Programming and Scripting

Regular Expression on Directory Contents

This should be an easy question for you gurus. :) How can I create a regular expression to match all files in the current directory that have only one period in their file name, and also not contain the string "abc" before the period? It would match: foo.txt foobar.log It would not... (4 Replies)
Discussion started by: blondie53403
4 Replies

3. Shell Programming and Scripting

Regular Expression to copy files

Hi All, I have a file with the contents as below. Current_path/file1 Current_path/file2 Current_path/file3 Now i want a regular expression to copy this files to cp Current_path/file1 HOME_DIR/Current_path/file1 cp Current_path/file2 HOME_DIR/Current_path/file2 cp Current_path/file3 ... (2 Replies)
Discussion started by: girish.raos
2 Replies

4. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

5. Shell Programming and Scripting

copying files using regular expression

I have 3 files names as HU123.IHS ,SU345.IHS DU567.IHS I have written a script to copy the files to the destination server but I am getting the error. /bin/cp '/dun/homes/11.3.7/packages/HU*.IHS' /dun/homes/11.3.7/Target But I am getting one error :- /bin/cp: cannot stat... (1 Reply)
Discussion started by: maitree
1 Replies

6. Shell Programming and Scripting

apply record separator to multiple files within a directory using awk

Hi, I have a bunch of records within a directory where each one has this form: (example file1) 1 2 50 90 80 90 43512 98 0909 79869 -9 7878 33222 8787 9090 89898 7878 8989 7878 6767 89 89 78676 9898 000 7878 5656 5454 5454 and i want for all of these files to be... (3 Replies)
Discussion started by: amarn
3 Replies

7. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

8. UNIX for Dummies Questions & Answers

Compare files with regular expression

Readers, Reading a previous post about comparing files using awk ('awk-compare-2-columns-2-files-output-whole-line', https://www.unix.com/shell-programming-scripting/168432-awk-compare-2-columns-2-files-output-whole-line.html), it is possible to adjust this, so that regular expression can be used... (8 Replies)
Discussion started by: linuxr
8 Replies

9. Shell Programming and Scripting

Apply argument to all files in directory

Hi all: i need to run a rather simple command-line argument: head -200 input > output However, I need to do it on several files, all in the same directory. Is this possible? (2 Replies)
Discussion started by: owwow14
2 Replies

10. Shell Programming and Scripting

How to find regular expression for two files?

I have files: sum_<INPUT FILENAME>.YYYYMMDDhhmmss.csv and sum_details_<INPUT FILENAME>.YYYYMMDDhhmmss.csv I have no idea, what is input filename, but in the code I would like to catch them in case I process them in the loop above case statement for *.${Today}.*.txt... (3 Replies)
Discussion started by: digioleg54
3 Replies
GENCFU(1)							 ICU 50.1.2 Manual							 GENCFU(1)

NAME
gencfu - Generates Unicode Confusable data files SYNOPSIS
gencfu [ -h, -?, --help ] [ -V, --version ] [ -c, --copyright ] [ -v, --verbose ] [ -d, --destdir destination ] [ -i, --icudatadir direc- tory ] -r, --rules rule-file -w, --wsrules whole-script-rule-file -o, --out output-file DESCRIPTION
gencfu reads confusable character definitions in the input file, which are plain text files containing confusable character definitions in the input format defined by Unicode UAX39 for the files confusables.txt and confusablesWholeScript.txt. This source (.txt) format is also accepted by ICU spoof detectors. The files must be encoded in utf-8 format, with or without a BOM. Normally the output data file has the .cfu extension. OPTIONS
-h, -?, --help Print help about usage and exit. -V, --version Print the version of gencfu and exit. -c, --copyright Embeds the standard ICU copyright into the output-file. -v, --verbose Display extra informative messages during execution. -d, --destdir destination Set the destination directory of the output-file to destination. -i, --icudatadir directory Look for any necessary ICU data files in directory. For example, the file pnames.icu must be located when ICU's data is not built as a shared library. The default ICU data directory is specified by the environment variable ICU_DATA. Most configurations of ICU do not require this argument. -r, --rules rule-file The source file to read. -w, --wsrules whole-script-rule-file The whole script source file to read. -o, --out output-file The output data file to write. VERSION
1.0 COPYRIGHT
Copyright (C) 2009 International Business Machines Corporation and others ICU MANPAGE
24 May 2009 GENCFU(1)
All times are GMT -4. The time now is 08:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy