Sponsored Content
Top Forums Shell Programming and Scripting How to add a new line into a file Post 302077322 by blowtorch on Wednesday 21st of June 2006 06:30:37 AM
Old 06-21-2006
The echo command should by default be putting a newline char at the end of each line. But if it isn't, you can specify the newline char, like this:
Code:
echo " san \n"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add a line to a file.

Hi I need to add a line to several files. But this line can only be added if it has an 'a' or 'A' in its current first line and only for the first line of each file. I tried sed, but i cant figure how to make it change just the first line. It just changes me all lines with an a. Can you give... (2 Replies)
Discussion started by: Scarlos
2 Replies

2. Shell Programming and Scripting

Add a line to a file

Hi I want to search for a string and add a new line after that line in the file. Say I have a file Input file adfad aadfsdfsa adfadsf <name>TypeOptions</name> adfdasf adfad adfad outputfile adfad aadfsdfsa adfadsf <name>TypeOptions</name> <option xsi:type="metadata:Option"... (3 Replies)
Discussion started by: ammu
3 Replies

3. Shell Programming and Scripting

Add new parameters into a line, and redirect the line to other file

How can i add new parameters into a line, and redirect the line to other file? For example: 1.sh name:owner google:richard youtube:student I want a, for example 2.sh with: name:owner:description google:richard:search site youtube:student:video site In the 2.sh, I added a new column:... (7 Replies)
Discussion started by: rafazz
7 Replies

4. Shell Programming and Scripting

howto add line as a first line into a non empty file

Hi Trying to do like this : echo "$variable1\n $(cat file.txt)" but it only adds one time. When I run this cmd again with different variable it only replaces line of variable1. How to add constantly line into first line in file ? (3 Replies)
Discussion started by: presul
3 Replies

5. Linux

Add file's date at beginning of every line in file

How would I do that? /Rutger (6 Replies)
Discussion started by: rutgerblom
6 Replies

6. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

7. Shell Programming and Scripting

Add line break for each line in a file

I cannot seem to get this to work.. I have a file which has about 100 lines, and there is no end of line (line break \n) at the end of each line, and this is causing problem when i paste them into an application. the file looks like this this is a test that is a test balblblablblhblbha... (1 Reply)
Discussion started by: fedora
1 Replies

8. Shell Programming and Scripting

Modify a file by another file: add new line and variable after string is found

hello, I have problem with writing/adjusting a shell script. I searched forum and unfortunately couldn't write scipt based on the information I found. I never wtire such so it's hard for me and I do need to modify one script immediately. case looks like: 1. 'file' that needs to be modified... (3 Replies)
Discussion started by: bipbip
3 Replies

9. Shell Programming and Scripting

create txt file form data file and add some line on it

Hi Guys, I have file A.txt File A Data AK1521 AK2536 AK3164 I want create text file of all data above and write some data on each file. want Output on below folder /home/kka/out AK1521.txt Hi Welocme (3 Replies)
Discussion started by: asavaliya
3 Replies

10. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies
echo(1) 						      General Commands Manual							   echo(1)

NAME
echo - Writes its arguments to standard output SYNOPSIS
echo [-n] [string...] [Tru64 UNIX] The -n option is valid only if the environment variable CMD_ENV is set to bsd. Note The C shell has a built-in version of the echo command. If you are using the C shell, and want to guarantee that you are using the command described here, you must specify the full path /usr/bin/echo. See the csh(1) reference page for a description of the built-in command. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: echo: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] No newline is added to the output. The -n option is valid only if the environment variable CMD_ENV is set to bsd. Otherwise any -n operand is treated as a string rather than as a option. See the printf(1) reference page for use in portable applications. OPERANDS
The string to be displayed on standard output. The echo command recognizes the following special characters in the string: Displays an alert character. Displays a backspace character. Suppresses the newline character. All characters following c in the arguments are ignored. Displays a formfeed character. Displays a newline character. Displays a carriage-return character. Displays a tab character. Displays a vertical tab character. Displays a backslash character. Displays an 8-bit character whose value is the 1-, 2- or 3-digit octal number, number. The first digit of number must be a 0 (zero). DESCRIPTION
The echo command writes the specified string to standard output, followed by a newline character. The arguments are separated by spaces. Use the echo command to produce diagnostic messages in command files and to send data into a pipe. If there are no arguments, the echo command outputs a newline character. [Tru64 UNIX] The echo command described here is the program /usr/bin/echo. Both csh and sh shells contain built-in echo subcommands, which do not necessarily work in the same way as the /usr/bin/echo command. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To write a message to standard output, enter: echo Please insert diskette . . . To display a message containing special characters as listed in DESCRIPTION, enclose the message in quotes, as follows: echo " I'm at lunch. I'll be back at 1 p.m." This skips three lines and displays the message: I'm at lunch. I'll be back at 1 p.m. Note You must enclose the message in quotation marks if it contains escape sequences such as . Otherwise, the shell treats the back- slash () as an escape character. The previous command example, entered without the quotes, results in the following output: nnnI'm at lunch.nI'll be back at 1 p.m. To use echo with pattern-matching characters, enter: echo The back-up files are: *.bak This displays the message The back-up files are: and then displays the file names in the current directory ending with To add a sin- gle line of text to a file, enter: echo Remember to set the shell search path to $PATH. >>notes This adds the message to the end of the file notes after the shell substitutes the value of the PATH shell variable. To write a message to the standard error output (sh only), enter: echo Error: file already exists. >&2 Use this in shell procedures to write error messages. If the >&2 is omitted, then the message is written to the standard output. ENVIRONMENT VARIABLES
The following environment variables affect the execution of echo: [Tru64 UNIX] This variable must set to bsd for the -n option to be valid. Otherwise any -n operand is treated as a string member. Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: csh(1), ksh(1), printf(1), Bourne shell sh(1b), POSIX shell sh(1p) Environment: environ(5) Standards: standards(5) echo(1)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy