Sponsored Content
Full Discussion: Problem with echo and cut
Top Forums UNIX for Dummies Questions & Answers Problem with echo and cut Post 302878567 by Yoda on Friday 6th of December 2013 11:17:38 PM
Old 12-07-2013
That for loop with cat is not recommended

You should use a while loop instead, try something like:
Code:
#!/bin/bash

while IFS="," read v1 v2 v3 v4 v5
do
        printf "%s\n" "$v2"
        printf "%s,%s,%s,%s,%s\n" "$v1" "$v2" "$v3" "$v4" "$v5"
done < src.src

This User Gave Thanks to Yoda For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

`echo` problem.

Have the following lines in a script: echo "-----------------------------------------------"\ "---------------------" >> $xdfrpt echo "- Date - - / - /stand - /u - /u1 - /u2 -"\ "/x1 - /x2 - /x3 -" >> $xdfrpt echo... (1 Reply)
Discussion started by: Cameron
1 Replies

2. Shell Programming and Scripting

echo problem

Hi, I have given the following statement in a script to put the values of variables (VAR1, VAR2,...) in a file. echo " $VAR1 $VAR2 $VAR3 $VAR4 $VAR5" >> filename But the output is not coming properly. Variables VAR5, VAR4 are replacing the first (VAR1, VAR2,..). I can't... (5 Replies)
Discussion started by: abrd600
5 Replies

3. Shell Programming and Scripting

echo problem

echo "XXXXX" >> /xx/output.txt cat /xx/file.txt| awk '{tony=tony+$1+$2; print tony/$3*100}' >> /xx/output.txt Dear all, In this situation i will have 2 lines in the output file. What i want is to have only one output line. e.g: XXXXX "value" HOW to put the output of the "cat and awk" in... (1 Reply)
Discussion started by: tontal
1 Replies

4. UNIX for Dummies Questions & Answers

echo $ problem

Hi I am using tcsh. I want display in a file_1 like this. $VARIBALE I gave in a termianl > echo "\$VARIBALE" > file_1 Its not workning. It was giving VARIBALE: Undefined variable. I gave \ before $, but why it was giving undefined varible? Please help me. Thanks in advance (4 Replies)
Discussion started by: chaitubek
4 Replies

5. Shell Programming and Scripting

storing output from echo & cut into variable

Hi All, Hope someone can advise here as I have been struggling to find a syntax that works here. I have tried a stack of combination I have seed in the forums but I think because I have needed to use "" and `` in the statments another method is found. I am reading in lines with the following... (1 Reply)
Discussion started by: nkwilliams
1 Replies

6. Shell Programming and Scripting

Problem with echo *

Hello all, Please help with the below. I have a requirement where in I have to read a pattern and print it as shown below. Patterns will be as below. Input Output Pattern Should be printed as below with spaces such that I can awk. -*--* - * - - * *--**... (2 Replies)
Discussion started by: tenderfoot
2 Replies

7. Shell Programming and Scripting

why the set rr='echo string|cut not working

I am new to the c shell script, can you let me know why the set rr= is not working. C shell script #! /bin/csh Set tt= 12345_UMR_BH452_3_2.txt set rr='echo $tt | cut –d”_” -f1' syntax error (4 Replies)
Discussion started by: jdsignature88
4 Replies

8. Shell Programming and Scripting

Advice using cut & echo combination commands

Hi, I am cutting data from a fixed length test file and then writing out a new record using the echo command, the problem I have is how to stop multiple spaces from being written to the output file as a single space. Example: cat filea | while read line do field1=`echo $line | cut -c1-2` ... (6 Replies)
Discussion started by: dc18
6 Replies

9. Shell Programming and Scripting

echo problem

hi all i have little problem below is my shell script a=`sqlplus fss_cst/fss_cst@dolp1 << EOF SET PAGESIZE 0 FEEDBACK OFF TRIMOUT ON; select process from lfs$ta_process where valid_to_dat=to_date('9/16/2010','mm/dd/yyyy'); EOF` echo ${SQL} the script name is test2.sh when i execute... (5 Replies)
Discussion started by: aishsimplesweet
5 Replies

10. Shell Programming and Scripting

Simple echo problem

Hey all! I'm in an intro to UNIX class at university, and we've just began writing scripts. Naturally I can't get it to do what I want. Basic script as follows: COMPARE1=`ls|wc -l` tar czf archive.tgz ~/path/to/file COMPARE2=`tar tvzf archive.tgz|wc -l` if then ... (7 Replies)
Discussion started by: nickzourdos
7 Replies
IMAGEPALETTETOTRUECOLOR(3)						 1						IMAGEPALETTETOTRUECOLOR(3)

imagepalettetotruecolor - Converts a palette based image to true color

SYNOPSIS
bool imagepalettetotruecolor (resource $src) DESCRIPTION
Converts a palette based image, created by functions like imagecreate(3) to a true color image, like imagecreatetruecolor(3). PARAMETERS
o $ image -An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(3). RETURN VALUES
Returns TRUE if the convertion was complete, or if the source image already is a true color image, otherwise FALSE is returned. EXAMPLES
Example #1 Converts any image resource to true color <?php // Backwards compatiblity if(!function_exists('imagepalettetotruecolor')) { function imagepalettetotruecolor(&$src) { if(imageistruecolor($src)) { return(true); } $dst = imagecreatetruecolor(imagesx($src), imagesy($src)); imagecopy($dst, $src, 0, 0, 0, 0, imagesx($src), imagesy($src)); imagedestroy($src); $src = $dst; return(true); } } // Helper closure $typeof = function() use($im) { echo 'typeof($im) = ' . (imageistruecolor($im) ? 'true color' : 'palette'), PHP_EOL; }; // Create a palette based image $im = imagecreate(100, 100); $typeof(); // Convert it to true color imagepalettetotruecolor($im); $typeof(); // Free the memory imagedestroy($im); ?> The above example will output: typeof($im) = palette typeof($im) = true color SEE ALSO
imagecreatetruecolor(3), imageistruecolor(3). PHP Documentation Group IMAGEPALETTETOTRUECOLOR(3)
All times are GMT -4. The time now is 02:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy