Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Output to file print as single line, not separate line Post 302985839 by rbatte1 on Wednesday 16th of November 2016 04:53:45 AM
Old 11-16-2016
Assuming you have a loop of some sort around your output statement, you could do something like this:-
Code:
for var in AA BB CC
do
   printf "%s" "$var"
done
printf "\n"

It's up to you where you want to set the redirection to append to the file. If you want to overwrite the file each time, you can perform a file open with:-
Code:
{ for var in AA BB CC
do
   printf "%s" "$var"
done
printf "\n"
} > output_file

I have written the printf with two arguments in case $var contains spurious data that could cause printf to do something unexpected. Some people find this annoying but it protects you somewhat from potentially damaging input.



I hope that this helps,
Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate lines in a single '|' separated line

Hi I have a file with contents like china india france japan italy germany . . . . etc.... I want the output as china|india|france|japan|italy|germany|.|.|. (3 Replies)
Discussion started by: hidnana
3 Replies

2. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

3. Shell Programming and Scripting

How to print the output in single line

Hi, Please suggest, how to get the output of below script in single line, its giving me in different lines ______________________ #!/bin/ksh export Path="/abc/def/ghi"; Home="/home/psingh/prat"; cd $Path; find $Path -name "*.C#*" -newer "abc.C#1234" -print > $Home cat $Home | while... (1 Reply)
Discussion started by: Prat007
1 Replies

4. Shell Programming and Scripting

extract nth line of all files and print in output file on separate lines.

Hello UNIX experts, I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines. e.g. The input Files are one.txt, two.txt, three.txt, four.txt The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies

5. Shell Programming and Scripting

awk/sed script to print each line to a separate named file

I have a large 3479 line .csv file, the content of which looks likes this: 1;0;177;170;Guadeloupe;x 2;127;171;179;Antigua and Barbuda;x 3;170;144;2;Umpqua;x 4;170;126;162;Coos Bay;x ... 1205;46;2;244;Unmak Island;x 1206;47;2;248;Yunaska Island;x 1207;0;2;240;north sea;x... (5 Replies)
Discussion started by: kalelovil
5 Replies

6. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

7. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips 10.26.208.28 10.26.208.26 10.26.208.27 want to convert above single line output as below format. Pls advice how to do ? 10.26.208.28 10.26.208.26 10.26.208.27 Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

8. Shell Programming and Scripting

Multiple pattern match and print the output in a single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log: 2013/06/11 14:29:04 <0999> (725102) Processing batch 02_1231324 2013/06/11... (4 Replies)
Discussion started by: rpm120
4 Replies

9. Programming

Read text from file and print each character in separate line

performing this code to read from file and print each character in separate line works well with ASCII encoded text void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int... (1 Reply)
Discussion started by: khaled79
1 Replies

10. Shell Programming and Scripting

awk to print line is values between two fields in separate file

I am trying to use awk to find all the $3 values in file2 that are between $2 and $3 in file1. If a value in $3 of file2 is between the file1 fields then it is printed along with the $6 value in file1. Both file1 and file2 are tab-delimited as well as the desired output. If there is nothing to... (4 Replies)
Discussion started by: cmccabe
4 Replies
destroy_pset(3) 					     Library Functions Manual						   destroy_pset(3)

NAME
destroy_pset - Destroys a processor set LIBRARY
Pset Library (libpset.a) Mach Library (libmach.a) SYNOPSIS
#include <sys/types.h> #include <sys/processor.h> int destroy_pset( int pset_id, [1 | 0]); PARAMETERS
Specifies the identification number for the processor set that you want to destroy. The pset_id processor set identification number is returned by a successful create_pset() call. A second argument may be required if there are threads or processors assigned to the proces- sor set. A value of 1 will force the destruction of the pset. A value of 0 will not force destruction automatically but will first prompt the user. DESCRIPTION
The destroy_pset function destroys a processor set. A processor that belongs to a destroyed processor set is returned to the default pro- cessor set. You must have root privileges. EXAMPLES
The following is example code for pset_destroy.c using the destroy_pset call: retval = destroy_pset(pset_id, 0); if (retval == PROCESSOR_SET_ACTIVE) { printf ("processor set %d has active ", pset_id); printf ("processors/tasks/threads assigned to it.0); printf ("destroy anyway? (y/n): "); while ((char)c != 'y' && (char)c != 'n') c = getchar(); if ((char)c == 'y') { retval = destroy_pset(pset_id, 1); if (retval != KERN_SUCCESS) { print_pset_error(retval); RETURN VALUES
If the destroy_pset function succeeds, it returns a zero (0). If it fails, it returns a negative number. Use this number and the print_pset_error(3) function to print a message that describes the error. Processor set destruction is logged in the /var/adm/wtmp file. FILES
/var/adm/wtmp RELATED INFORMATION
create_pset(3), assign_cpu_to_pset(3), assign_pid_to_pset(3), print_pset_error(3), processor_sets(4), pset_create(1) delim off destroy_pset(3)
All times are GMT -4. The time now is 09:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy