Sponsored Content
Top Forums Shell Programming and Scripting Trouble printing multiple lines to a new file Post 302580877 by racshot65 on Saturday 10th of December 2011 04:59:02 PM
Old 12-10-2011
Trouble printing multiple lines to a new file

Hi,

I'm trying to auto generate some php files with a default preamble at the top which is a block comment.

The problem is that my output has no new lines and it looks like the output from "ls" is being printed after everyline


This is my code

Code:
#!/bin/bash

read -d '' pre_amble <<"EOF"
/** 
 *
 * Default comment block at top of file
 *
 * etc etc 
 *
 * contains things like copyright info
 *
 * and author name etc
 *
 * 
 * 
 */
EOF
echo $pre_amble > 'test.php'


And this is what is in 'test.php' after the script has executed (emphasis added to make it easier to read)


Quote:
/bin /boot /cdrom /dev /etc /home /host /initrd.img /initrd.img.old /lib /lost+found /media /mnt /opt /proc /root /sbin /selinux /srv /sys /tmp /usr /var /vmlinuz /vmlinuz.old build COPYING docs extras logs README.md tests webapp build COPYING docs extras logs README.md tests webapp Default comment block at top of file build COPYING docs extras logs README.md tests webapp build COPYING docs extras logs README.md tests webapp etc etc build COPYING docs extras logs README.md tests webapp build COPYING docs extras logs README.md tests webapp contains things like copyright info build COPYING docs extras logs README.md tests webapp build COPYING docs extras logs README.md tests webapp and author name etc build COPYING docs extras logs README.md tests webapp build COPYING docs extras logs README.md tests webapp build COPYING docs extras logs README.md tests webapp build/ docs/ extras/ logs/ tests/ webapp/

Any ideas ?

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trouble with printing to other folders w/ awk

Again, I am in need of some advice. Earlier I was shown how to have awk create folders for me. That was so cool and helpful, but now I am exploring the posibilities of combining operations with bash scripts. Now, I am creating the directories with the bash script, and then I want awk to... (1 Reply)
Discussion started by: ccox85
1 Replies

2. Shell Programming and Scripting

printing first n lines in a file without using head

i have to print first n lines of a file. how can i do that without using head command. for some reason i do not want to use Head. is there a way to get that result using awk or sed?. i an using this on korn shell for AIX Thanks.. (7 Replies)
Discussion started by: dareman123
7 Replies

3. Shell Programming and Scripting

Printing out multiple lines with a correct format

Hello, This is my first post and I've just started on UNIX in school. A file name "list" has the following content (excluding the numbers and the bottom part): 1 2 3 4 5 6 0123456789012345678901234567890123456789012345678901234567890 IT ... (1 Reply)
Discussion started by: cooolway
1 Replies

4. Shell Programming and Scripting

Perl: Printing Multiple Lines after pattern match

Hello People, Need some assistance/guidance. OUTLINE: Two files (File1 and File2) File1 has some ids such as 009463_3922_1827 897654_8764_5432 File2 has things along the lines of: Query= 009463_3922_1827 length=252 (252 letters) More stufff here ... (5 Replies)
Discussion started by: Deep9000
5 Replies

5. Shell Programming and Scripting

printing lines to a file from a particular string

Hi, A very Good Evening to All, I am writing a script for my application. I have a file with 1000 lines. Among that 1000 lines i am searching for a particular string. And from that string i need to pull all the data in to a seperate file. For example the contents of my file is as below. ... (4 Replies)
Discussion started by: intiraju
4 Replies

6. Shell Programming and Scripting

Need Help with grep printing multiple lines.

I need help in printing multiple lines using a grep command. The situation is like this. I have a file that contains large number of lines Now I need to find the the lines in the file such that if the word "AllServiceType" is found then the next line also gets printed. Does anyone... (6 Replies)
Discussion started by: m_usmanayub
6 Replies

7. Shell Programming and Scripting

Printing the lines that appear in an other file, and the three lines after them

Hi ! I need some help with a script I am writing. I am trying to compare two files, the first file being in this format : Header1 Text1-1 Text1-2 Text1-3 Header2 Text2-1 etc... For each header, I want to check if it appears in the second file, and if it is the case print the header... (4 Replies)
Discussion started by: jbi
4 Replies

8. Shell Programming and Scripting

Printing multiple columns from a file

Hi, I need just to print the values of second and fourth column from a file # cat dispaly id Name Std Specialist 1 sss X mathematics 2 uyt IX geography 3 vcd X English i tried with some NF command.. I think am wrong.. Is there anyother way to print my requirement (3 Replies)
Discussion started by: Priya Amaresh
3 Replies

9. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

10. Shell Programming and Scripting

Printing multiple lines on the same line between specific text

This is an extract from a large file. The lines that start with fc are ports on a fabric switch. In between each fc port there is information about the port. fc2/12 is up Port description is SEIEDISCOVER-3 Speed is 4 Gbps fc2/13 is down (Administratively down) fc2/14 is up Port... (1 Reply)
Discussion started by: kieranfoley
1 Replies
dbconfig-generate-include(1)					  dbconfig-common				      dbconfig-generate-include(1)

NAME
dbconfig-generate-include - generate custom format db include files SYNOPSIS
dbconfig-generate-include [-hv] [-f format] [-o options] [-a] [-d[varname]] [-u[varname]] [-p[varname]] [-s[varname]] [-P[varname]] [-t[varname]] [-C[commentstr]] [-O owner[:group]] [-m mode] [-U] infile [outfile] DESCRIPTION
dbconfig-generate-include is a program to generate custom format include files containing the information necessary to connect a program to a database resource. OPTIONS
infile use the given dbconfig-common config file as input outfile use the given file as input (default: stdout) -f|--format use the given output format (default: sh) -o|--options pass options specific to an output format in a semicolon seperated list. see OUTPUT FORMATS/OPTIONS for more information. -a|--all include all information in output (default) -d|--dbname include the dbname in the output -p|--dbpass include the dbpass in the output -s|--dbserver include the dbserver in the output -P|--dbport include the dbport in the output -u|--dbuser include the dbuser in the output -t|--dbtype include the dbtype in the output -C|--comment "comment out" any unset variables, using a string appropriate comment string for the programming language in question. can be over- ridden with an optional parameter as an arbitrary comment. -O|--owner set the owner:group of the output file -m|--mode set the permissions on the output file -U|--ucf register the outputfile with ucf -h|--help display this helpful message -v|--version output the version and exit OUTPUT FORMATS
/OPTIONS format is one of a list of include-file style formats for various programming languages. the current list includes: sh /bin/sh style include file. perl perl parseable include file. php php parseable include file. template a file which contains a series of fields to be replaced with actual values. all substitutable fields consist of the underlying dbc_ variable name capitalized and surrounded with underscores. for example: _DBC_DBUSER_. options: template_infile (path to input file containing template) cpp c-style header file, using #define'd constants. sean finney March 2005 dbconfig-generate-include(1)
All times are GMT -4. The time now is 08:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy