Quick question...

blasterpro

Registered Member
Joined
Jan 8, 2009
Messages
67
Reaction score
22
I have a list in a text file that has over 72,000 lines. I want insert {" before and "} after each line what is the quickest and easiest way to achieve this?

Thanks in advance
 
i can code a script to do it for you. please pm me with offer.
 
In Linux Bash

Save the following in a file named myshellscript.sh

Code:
while read lineoftext
do
echo "beforetext" "$lineoftext" "aftertext" >>resultfile.txt
done

Then from the commandline execute the command with:

Code:
cat fileyouwanttoedit.txt | sh ./myshellscript.sh

When it finishes the resultfile.txt is your edited file and your original file is untouched just in case you typo'd and need to do it again.
 
In Linux Bash

Save the following in a file named myshellscript.sh

Code:
while read lineoftext
do
echo "beforetext" "$lineoftext" "aftertext" >>resultfile.txt
done
Then from the commandline execute the command with:

Code:
cat fileyouwanttoedit.txt | sh ./myshellscript.sh
When it finishes the resultfile.txt is your edited file and your original file is untouched just in case you typo'd and need to do it again.


you bastard
 
4alllifestyles great spirit in helping someone out in BHW this is what this forum is about:D
 
If you are not a freetard want to do it in Windows, save the following as a vbs file (say a.vbs).

Then from the command prompt run "cscript a.vbs {your file}". To redirect outpu another file: ""cscript a.vbs {your file} > {output file}"

Code:
Option Explicit
Dim oFSO, sFile, oFile, sText
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = WScript.Arguments(0)
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
 Do While Not oFile.AtEndOfStream
  sText = oFile.ReadLine
   If Trim(sText) <> "" Then
    WScript.Echo "{" & sText & "}"
   End If
 Loop
oFile.Close
Else
WScript.Echo "File not found."
End If
 
Back
Top