and its being printed out 5 times, is there any way I can limit to only being displayed ONCE. I tried echo -n but that just makes everything fit on one line.
Right now it keeps saying
and I want it displayed only once
Do you have it in a loop? Sounds to me like something other than the echo is your problem.
It would be helpful to see your script along with the shell that you are using and O/S.
sure thing it is a for loop
what its doing is taking any file ending in .jpg in the current directory and making it into a thumbnail. I am running into a problem where I want it to display the error message only if no arguments are provided on the command line. I am not doing it right
Its my fault for trying to make it convert everything in the directory ending in .jpg using the FOR loop but I'm at the same time trying to feed an argument on the command line . . I am in a pickle... I would much rather just feed it command line but at the same time have it being able to take 1 argument or even a list but still give an error if no arguments are being displayed. Im new to this sorry. Any help is appreciated.
First off, there seems to be some confusion in your code:
What is the for loop supposed to cycle through? The arguments given or the files with a certain ending?
Apart from that, one of the three utilities in this pipeline:
now print an error message every time some error condition occurs. As the condition occurs repeatedly the message is printed several times.
If you want to print it only once use a flag (which you raise when the condition occurs) and only at the end print the message depending on the status of the flag. The usual way to do this is to redirect error messages to "/dev/null" and use the exit code of the program(s) as indication if everything has gone ok.
So, your code should look something like this:
But there is still some gotcha: in pipelines only one return code is given back and it not completely standardized which one this is. Depending on which OS and shell you use and which options you use (see for instance "set -o pipefail" in bash) you might get differing results.
You have a couple of options. Test before entering the for loop and exit immediately after writing the error message:
However, since you are not using the information on the command line it seems odd that you would require it be entered. Maybe you are intending to get parameters or something from the command line; if that is the case then this would allow for you to validate and continue if you get the information.
However, the message in your code implies that you want the user to enter an image file to convert. If they enter a file, do you want to just convert the ones on the command line, but default to converting everything if they don't enter any filename? If so, you could do something like this:
This invokes the conversion function once for each command line parm (the function probably should verify that it exists and is a proper file type etc.). If no parameters are entered, then it invokes the function for all jpg files in the current directory.
I've not really tested either of these, but you should get an idea of your options.
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
What single command line would you enter to get the following output?
8140 drwxr-xr-x 9 root bin 18 Jan 20... (6 Replies)
Hi All,
I want to display content on command promt and also write in file.
For that iI ahve to write two sentence
echo "XXXXXXX"
echo "XXXXXXXX" >> 1.txt
Is there any way to write in one echo statement (1 Reply)
Hi
I am facing a strange problem
a=03
echo ${a}
the output is 3
But i want to display it is 03
Can you people help me how to display it like 03.
Thanks (2 Replies)
Dear Friends,
I have my command output which displays on one row and values are now scrollable (vertical) 3 pages. How do i display those output in three column so that i no need to scroll?
Example:
dcadd$cat components
1.Caluculator
2.Diary
...
...
50.Mobile
51.Battery
..
...... (12 Replies)
Bit of a weird one i suppose, i want to use an echo inside an echo... For example...
i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos...
echo "echo "hello"" >$file
echo "echo "goodbye"" >$file
... (3 Replies)
Hi
I want to display "echo command value in loop" in single line. My requirement is to show the input file (test_1.txt) like the output file (test_2.txt) given below.
Input file :test_1.txt
a1|b1|4|5
a1|b1|42|9
a2|b2|32|25
a1|b1|2|5
a3|b3|4|8
a2|b2|14|6
Output file:test_2.txt... (2 Replies)
Hi,
My script prints a few varibales as each it reads each line of a text file and then prints them on screen, however iam having problem in aligning and sorting them.
what happens is this
Last First Number
Mark leo 87798798... (1 Reply)
I have a variable that is outputting a lot of space.
here has been 45 lines returned ...
how can I remove the spaces between the "been and the 45"
CODE:
fil_len=`wc -l < coshb.txt`
if ; then
cat coshb.txt | more
echo " "
echo "There has been ${fil_len} lines... (4 Replies)