how to replace . with 100 spaces


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to replace . with 100 spaces
# 1  
Old 11-06-2009
Question how to replace . with 100 spaces

i have a file like::
$ cat space
asd
fghj
itkg

now i want to replace the next line with . and thn this . with the 100 spaces.

cat space | tr '\n' '.', it woked for me, to replce the new line to .

Now i want to replace this . with 100 spaces.

Thanks in advance.
# 2  
Old 11-06-2009
Quote:
Originally Posted by Prashant Jain
...
now i want to replace the next line with . and thn this . with the 100 spaces.
...
I guess you mean "newline" and not "next line".
Why an additional step in between ? Why not replace newlines with 100 spaces directly ?

Quote:
...
cat space | tr '\n' '.', it woked for me, to replce the new line to .

Now i want to replace this . with 100 spaces.

...
Again, why substitute by the "." first ?

tyler_durden
# 3  
Old 11-06-2009
If directly we can do it, it will be great. Can you please send me the command.
# 4  
Old 11-06-2009
Do you want to replace the last character with 100 spaces?

Code:
cat fichero | sed "s/$/`perl -e 'print \" \" x 100'`/"

# 5  
Old 11-06-2009
Or using just Perl:

Code:
$
$ cat space
asd
fghj
itkg
$
$ perl -ne '$x = " "x10; s/\n/$x/g; print' space
asd          fghj          itkg          $
$
$

Replace 10 by 100 in the one-liner above.

tyler_durden
# 6  
Old 11-06-2009
Code:
perl -e ' while (<>) { print $_ ," "x100;} ' filename

# 7  
Old 11-06-2009
Quote:
Originally Posted by pogdorica
Do you want to replace the last character with 100 spaces?

Code:
cat fichero | sed "s/$/`perl -e 'print \" \" x 100'`/"


Here i hope no need to use "cat".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to replace two or more spaces with one comma?

I'm using sh on hp-ux. I've got a file that looks like this. -5.65 175 -16.17 160 -13.57 270 -51.72 260 -8.30 360 -42.71 460 -.38 375 -.20 375 -4.15 170 -21.53 560 -18.84 360 I'd like to replace all the whitespace between the columns with one comma. I can't... (4 Replies)
Discussion started by: Scottie1954
4 Replies

2. Shell Programming and Scripting

String replace that has spaces

cat rf|nawk '/Use SSL= 0/{n+=1}{if (n==3){sub("Use SSL= 0","Use SSL= 0x1",$0)};print }' > rf2Fails. sed 's/Use SSL= 0/Use SSL= 0x1/g' rf > rf2Fails. In addition, the goal is to ONLY replace the 2nd occurence of the... (15 Replies)
Discussion started by: rfransix
15 Replies

3. Shell Programming and Scripting

replace spaces/tabs with delimiter |

Hi, I'm looking for a command that replaces spaces/tabs with pipe symbol and store the result to the same file instead of routing it to another file. infile outfile Thanks. (11 Replies)
Discussion started by: dvah
11 Replies

4. Shell Programming and Scripting

Replace with spaces

Hi Guys file:///C:/DOCUME%7E1/c104058/LOCALS%7E1/Temp/moz-screenshot.pngsed 's///g' /source/filename.txt > /destination/filename.txt The above code deletes the characters which are not A-Z, a-z and 0-9, but I wanted to replace it with space without deleting them. Any help is... (2 Replies)
Discussion started by: gowrishankar05
2 Replies

5. UNIX for Dummies Questions & Answers

how to replace spaces with '_' in a file?

Hello #I have a file with a list of sequences; the sequence name is the line starting with '>'. $cat infile >AluYa5 SINE1/7SL Homo sapiens ggccgggcgcggtggctcacgcctgtaatcccagcactttgggaggccgaggcgggcggatcacgaggtc aggagatcgagaccatcccggctaaaacggtgaaaccccgtctctactaaaaatacaaaaaattagccgg... (11 Replies)
Discussion started by: jdhahbi
11 Replies

6. Shell Programming and Scripting

replace 2 spaces by one

Dear Friends, I have a flat file from which I want to remove single "space". And, wherever two spaces are provided it should replace it by only one space. E.g. I have N A T I O N A L E D U C A T I O N F O R O R G AN I S A T I ON S I want NATIONAL EDUCATION FOR ORGANISATIONS Please... (5 Replies)
Discussion started by: anushree.a
5 Replies

7. UNIX for Dummies Questions & Answers

Replace tab or any spaces with "

my content: samaccountname employeeid useraccountcontrol description i want it to look like this: "samaccountname","employeeid","useraccountcontrol","description" (2 Replies)
Discussion started by: tjmannonline
2 Replies

8. Shell Programming and Scripting

Replace spaces

Hi guys, so I have another issue. Can I use sed to replace spaces in a string or variable with %20 I am having trouble with using curl on URL's containing spaces Thanks! (12 Replies)
Discussion started by: tret
12 Replies

9. Shell Programming and Scripting

Remove spaces between charc and replace it with ','.

Hi, Below is my output file: (The below line has multiple spaces bet charc and I want to replace spaces with "," only for the first line) NYCCMS97KJ931 01-JUN-08 1214957 I want this to be: ... (5 Replies)
Discussion started by: smc3
5 Replies

10. Shell Programming and Scripting

Replace spaces recursively

Hi, I have a directory with files and sub-directories (sub-directory depth might go upto 5). There will be one or more spaces (continuously or anywhere in the file name) which need to be replaced with HYPHENs. How can i replace all SPACE occurances with HYPHEN in file/dir names recursively. (2... (5 Replies)
Discussion started by: prvnrk
5 Replies
Login or Register to Ask a Question