Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to use sed to insert character in the beginning of file path? Post 303039318 by RudiC on Monday 30th of September 2019 05:41:40 PM
Old 09-30-2019
Did you read and understand my quote from info sed?
Quote:
The '/' characters may be uniformly replaced by any other single character within any given 's' command. The '/' character (or whatever other character is used in its stead) can appear in the REGEXP or REPLACEMENT only if it is preceded by a '\' character.
So my command reads
Code:
s#pattern#replacement#

as the / is part of both pattern and replacement. The delimiter or separator is #, the pattern is /, and the replacement is /bck1/.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a character in the beginning of every line in a .dat file

How can i add a character(#) in the beginning of every line in a .dat file (2 Replies)
Discussion started by: Cool Coder
2 Replies

2. UNIX for Dummies Questions & Answers

How can I insert character to end of file?

Hello all How can I insert character to the end of text file without opening it in vi Just simple one liner, can it be done? Tnx (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

Insert two strings at the beginning and at the end of each line of a file

Hi, excuse me for my poor english. My problem is that: I have a File i want to add to each line of that file two strings: one at the beginning of the line, one at the ending. string1="abcd" string2="efgh" i want $string1 content $string2 for each line. Is that possible? (3 Replies)
Discussion started by: Linux-fueled
3 Replies

4. UNIX for Dummies Questions & Answers

Remove words beginning with a certain character from a file

Hi, how could you go about removing words that begin with a certain character. assuming that this character is '-' I currently have echo "-hello" | sed s/-/""/ which replaces the leading dash with nothing but I want to remove the whole word, even if there are multiple words beginning... (3 Replies)
Discussion started by: skinnygav
3 Replies

5. Shell Programming and Scripting

Need to insert text(constant) at the beginning of file

I am very new to scripting and I know this request is simple but I am having no luck with it. I have a file a.dat with the following data in it. aa bb cc dd I need to run a script that will take each line of a.dat and put dsjc/ubin/ in front of each record, so the output looks like ... (2 Replies)
Discussion started by: jclanc8
2 Replies

6. Shell Programming and Scripting

SED - insert space at the beginning of line and multi replace command

hi I am trying to use SED to replace the line matching a pattern using the command sed 'pattern c\ new line ' <file1 >file 2 I got two questions 1. how do I insert a blank space at the beginning of new line? 2. how do I use this command to execute multiple command using the -e... (5 Replies)
Discussion started by: piynik
5 Replies

7. Shell Programming and Scripting

Insert output from a file to beginning of line with sed

Hi I've been trying to search but couldn't quite get the answer I was looking for. I have a a file that's like this Time, 9/1/12 0:00, 1033 0:10, 1044 ... 23:50, 1050 How do I make it so the file will be like this? 9/1/12, 0:00, 1033 9/1/12, 0:10, 1044 ... 9/1/12, 23:50, 1050 I... (4 Replies)
Discussion started by: diesel88
4 Replies

8. Shell Programming and Scripting

sed to insert a character

Hi all, I have a file like this Q8N302 21-84 Q8N157 15-45 Q99996 167-201 202-251 269-318 I want to insert a character or space if the line starts with a number and I used the command sed 's/^/#/' But in the output file, when it inserts this character, first digit in the number is... (2 Replies)
Discussion started by: kaav06
2 Replies

9. Shell Programming and Scripting

sed - replacement file path with variable - Escaping / character

Hi,, I have the line below in a file: $!VarSet |LFDSFN1| = '"E:\APC\Trials\20140705_427_Prototype Trial\Data\T4_20140705_Trial_Cycle_Data_13_T_Norm.txt" "VERSION=100 FILEEXT=\"*.txt\" FILEDESC=\"General Text\" "+""+"TITLE{SEARCH=NONE NAME=\"New Dataset\" LINE=1I want to write a script to change... (2 Replies)
Discussion started by: carlr
2 Replies

10. UNIX for Advanced & Expert Users

Insert a column in the beginning

Hi, I have been trying to see how i can insert a column in the beginning to my html table This is how it looks Name Age Sid 32 John 33 Mary 34 I want to insert a column Job before Name column, so it looks like Job Name Age IT Sid 32 Doctor... (3 Replies)
Discussion started by: sidnow
3 Replies
RREP(1) 						      General Commands Manual							   RREP(1)

NAME
rrep - replace patterns in files. SYNOPSIS
rrep [OPTIONS] PATTERN REPLACEMENT [FILE...] DESCRIPTION
The rrep utility searches input FILEs for matches to a given PATTERN and replaces those matches by a given REPLACEMENT. The pattern is, by default, a basic regular expression. The replacement string may contain special characters to refer to portions of the matched pattern. Binary files are, by default, ignored. A file is regarded as binary if it contains the null character. OPTIONS
-E, --extended-regexp PATTERN is interpreted as an extended regular expression (ERE). -F, --fixed-strings PATTERN and REPLACEMENT are interpreted as fixed strings, not as regular expressions or escape sequences. -R, -r, --recursive Each directory that is given on the command line is processed recursively. Files and sub-directories starting with the . character are, by default, ignored. --include=FILE_PATTERN Only files are processed that match the pattern FILE_PATTERN, except for files that are specifically given on the command line. *, ?, and [...] can be used as wildcards in FILE_PATTERN. Wildcards and backslash characters can be quoted with . --exclude=FILE_PATTERN Files that match the pattern FILE_PATTERN will be skipped, except for files that are specifically given on the command line (using wildcard matching as described under --include). --exclude-dir=PATTERN Directories that match PATTERN will be skipped, except for files that are specifically given on the command line (using wildcard matching as described under --include). -V, --version Print the version number of rrep. -S SUFFIX, --suffix=SUFFIX Override default backup suffix. This option implicitly activates backups. -a, --all Files and sub-directories starting with the . character in recursively processed directories (see --recursive) are processed as well. -b Backup before overwriting files. The backup files are written into the directory of the original file. Equivalent to using --backup=existing. --backup[=CONTROL] Like -b but accepts a version control argument. The file name of the backup file is appended by a ~ character. The backup suffix is ~, unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if --backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups --binary Do not ignore binary files. A file is regarded as binary if it contains the null character . --dry-run The replacement is just simulated. No file is actually modified. -e PATTERN, --regexp=PATTERN Use PATTERN for matching. This option can be used to specify a pattern beginning with -. -h, --help Display a help message that descibes the command line options and exit afterwards. -i, --ignore-case Case distinctions in PATTERN are ignored. --keep-times The original access and modification times of files and directories are restored after processing. -p REPLACEMENT, --replace-with=REPLACEMENT Use REPLACEMENT for substitution. --interactive Each time before a file is modified the user is prompted and can cancel the modification. -q, --quiet, --silent All normal output messages are suppressed. -s, --no-messages All error messages are suppressed. -w, --word-regexp Only those matches of PATTERN are replaced that match whole words. -x, --line-regexp Only those matches of PATTERN are replaced that match whole lines. EXIT STATUS
Exit status is 1 if any error occurs, 0 otherwise. AUTHOR
Written by Arno Onken. REPORTING BUGS
If you find a bug in rrep, please send electronic mail to <asnelt@asnelt.org>. Include the version number, which you can find by running rrep --version. Also include in your message the output that the program produced and the output you expected. If you have other questions, comments or suggestions about rrep, contact the author via electronic mail to <asnelt@asnelt.org>. The author will try to help you out, although he may not have time to fix your problems. COPYRIGHT
Copyright 2011 Arno Onken This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
Regular Manual Pages find(1), grep(1), sed(1), xargs(1), regex(7). TeXinfo Documentation The full documentation for rrep is maintained as a TeXinfo manual. If the info and rrep programs are properly installed at your site, the command info rrep should give you access to the complete manual. User Commands rrep 1.3.3 RREP(1)
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy