You can use the powerful stream editor (sed) utility to convert a single-spaced file to a double-spaced file. Conversely, you can take a double-spaced file and convert it to a single-spaced file. Here's an illustration.
Single-spaced to double-spaced file
# more tstfile
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
Now output to stdout and tstfile1 -- double-spaced
# sed G tstfile | tee tstfile1
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
Verify tstfile1 is double-spaced
# more tstfile1
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
Double-spaced to single-spaced file
Now output to stdout and tstfile2 -- single-spaced
# sed 'n;d' tstfile1 | tee tstfile2
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
Verify tstfile2 is single-spaced
# more tstfile2
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
Extra...
To triple-spaced
# sed 'G;G' tstfile | tee tstfile1
To double-spaced
# sed 'n;n;d' tstfile1 | tee tstfile2
To single-spaced
# sed 'n;n;d' tstfile1 | sed 'n;d' | tee tstfile3
This blog covers Unix system administration HOWTO tips for using inline for loops, find command, Unix scripting, configuration, SQL, various Unix-based tools, and command line interface syntax. The Unix OS supports tasks such as running hardware, device drivers, peripherals and third party applications. Share tips/comments. Read the comments. But most importantly: Read Disclaimer - Read Disclaimer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment