Sponsored Content
Top Forums Shell Programming and Scripting SED Replacing all but one regex match on a line or specific matches Post 302518949 by vectox on Monday 2nd of May 2011 03:21:36 PM
Old 05-02-2011
SED Replacing all but one regex match on a line or specific matches

Hi,

I'm attempting to rename some files that have spaces in them. Without linking sed commands together is it possible to replace the first three "." to " ".

File.name.is.long.ext -> File name is long.ext

I can get the desired effect with

Code:
echo "File.name.is.long.ext" | sed 's/\./ /g;s/ /\./4'

Is it possible to do the same thing with just one command?

The following type of logic doesn't work
Code:
echo "File.name.is.long.ext" | sed 's/\./ /1~3'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace if regex on specific column matches expression?

I am attempting to convert rewrite rules to Nginx, and since due to the mass amount of rewrites we must convert, I've been trying to write a script to help me on a specific part, easily. So far I have this: rewrite ^action/static/(+)/$ staticPage.php?pg=$1&%$query_string; What I want done... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

2. Shell Programming and Scripting

Does Sed Search/Replace Work For Multiple Matches On The Same Line?

Hello, I would like to delete all the footnotes in all my htm files. Hence, I have to delete the whole font tag pairs, i.e. deleting everything between the begin/end font tags. I create a testfile, of which data parts of all four lines are the same except for the number of font tag pairs,... (3 Replies)
Discussion started by: cibalo
3 Replies

3. UNIX for Dummies Questions & Answers

replacing string in a column on a specific line

hi, i currently have a file with columns similar to this customer name owed CID123 John 300 CID342 harry 500 at present i use use awk to find the amount owed by the customer using the customer ID (CID). if the customer spends more money how would i go about using sed/awk etc to... (2 Replies)
Discussion started by: skinnygav
2 Replies

4. Shell Programming and Scripting

replacing field in specific line in a file

Hi, I know there are lots of threads on replacing text within files, usually using sed or awk. However, I find it hard to adapt examples that I found to my specific case. I am kind of new to UNIX and have hard times learning the syntax either for sed or awk so I would appreciate any help. Here's... (5 Replies)
Discussion started by: vytenis
5 Replies

5. Shell Programming and Scripting

Replacing specific characters using sed

Hi, I have a text file which is output from a server and it lists all the files in a specific volume. However, the volume name appears as volume_name:. I would like to replace this with \\volume_name\volume_name. This is not a problem in itself as I can use sed to globally look for the... (8 Replies)
Discussion started by: vnayak
8 Replies

6. Shell Programming and Scripting

Replacing specific entry using sed

Hi guys, I'm new to bash programming, so please pardon me. I'm trying to replace an entry's text in Books.txt This code works perfectly: sed -i "s/$BookTitle/$NewBookTitle/g" Books.txt But problem is, if there are double entries, it will also replace that entry. For example: ... (12 Replies)
Discussion started by: todaealas
12 Replies

7. Shell Programming and Scripting

Using regex's from file1, print line and line after matches in file2

Good day, I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after. file1: file2: Output: I can match a regex and print the line and line after awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } ' ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

8. Shell Programming and Scripting

Regex in sed to find specific pattern and assign to variable

(5 Replies)
Discussion started by: radioactive9
5 Replies

9. Shell Programming and Scripting

Regex: print matched line and exact pattern match

Hi experts, I have a file with regexes which is used for automatic searches on several files (40+ GB). To do some postprocessing with the grep result I need the matching line as well as the match itself. I know that the latter could be achieved with grep's -o option. But I'm not aware of a... (2 Replies)
Discussion started by: stresing
2 Replies

10. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies
sphinx-autogen(1)						   User Commands						 sphinx-autogen(1)

NAME
sphinx-autogen - generate ReStructuredText using autosummary directives SYNOPSIS
sphinx-autogen [-o output_dir] [-s suffix] sourcefile... OPTIONS
-o, --output-dir=output_dir, the directory the output files should be written to -s, --suffix=suffix the suffix of the written files (defaults to rst) -t, --templates=directory custom template directory DESCRIPTION
sphinx-autogen is a frontend to sphinx.ext.autosummary.generate. It generates the ReStructuredText files from the autosummary directives contained in the given input files. The format of the autosummary directive is documented in the sphinx.ext.autosummary Python module and can be read using pydoc sphinx.ext.autosummary SEE ALSO
sphinx-quickstart(1), sphinx-build(1) The Sphinx website <http://sphinx.pocoo.org/> AUTHOR
This man page was written by Jan Dittberner <jan@dittberner.info> for the Debian GNU/Linux System (but may be used by others). Sphinx 1.1 Aug 2010 sphinx-autogen(1)
All times are GMT -4. The time now is 09:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy