Sponsored Content
Top Forums UNIX for Dummies Questions & Answers I'm having problems with a simple for loop on a newline Post 302358593 by 64mb on Saturday 3rd of October 2009 10:28:58 AM
Old 10-03-2009
Quote:
Originally Posted by pen
One more to go - why use printf?
Code:
for f in $(seq 1 10); do echo -n $f; done; echo

BR,

pen
Haha, thanks. I didn't really understand what the -n argument did, from browsing the man, otherwise that's what I would have used. Thanks for that. Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

simple for loop

i have the following process running in background: when i give "ps -lef" ------------------------------------------------------------------------ user2 user1 user1 user3 user1 user4 user5 user4 user3 user4 user2 user1 user1 user3 user1 user4 (3 Replies)
Discussion started by: ali560045
3 Replies

2. Shell Programming and Scripting

Simple using For loop

Hi expert, I'm using csh Code: #!/bin/csh set x = 0 set number = `awk '{array=$0} END {print array;}'` i want to use for loop to store data to $number repeatly untill x = 23 How to use c shell for loop? (2 Replies)
Discussion started by: vincyoxy
2 Replies

3. Shell Programming and Scripting

Problems using join for simple database lookup

I am trying to get a script working that will perform a simple database lookup using the join command. Here are the two files that I am trying to join: % cat lookup1.txt Number_1 Other_data_a Number_5 Other_data_b Number_8 Other_data_c Number_10 Other_data_d % cat... (2 Replies)
Discussion started by: JasonHamm
2 Replies

4. UNIX for Dummies Questions & Answers

Simple loop

I need to chmod a bunch of files with a specific extension in one directory. If I understand correctly first I would run ls command like this ls -R | grep .mp3 > /tmp/list once I have the output file I should be able to run a loop to chmod all the files in the list created. This is where... (5 Replies)
Discussion started by: eugenes18t
5 Replies

5. Shell Programming and Scripting

Problems with simple script in cygwin

Hello! I have somo problems with simple scripts like this: #!/bin/bash echo -n "Enter your name and press : " read var_name echo "Your name is: $var_name" When I try to run it, this error occurs: ':not a valid identifier var_name. Why?? (I work in cygiwin) Is there anybody out... (10 Replies)
Discussion started by: blianna
10 Replies

6. Shell Programming and Scripting

Very Simple "Tabs to Newline" Code???

hi people; i have a text, iptables.txt and values are as follows inside: (seperators are TAB) 10.15.2.2 2 40 10.15.3.3 1 10 10.32.2.1 3 40 10.33.6.7 2 50 10.16.3.2 1 60 10.11.3.9 1 20 10.19.2.1 1 80 10.16.9.9 3 20 10.29.7.9 2 90 10.33.2.7 3 40 ...... i... (5 Replies)
Discussion started by: gc_sw
5 Replies

7. Programming

fgets problems newline

hello, i'm trying to write a C-program that reads a file line by line. (and searches each line for a given string) This file is an special ASCII-database-file, with a lot of entries. I checked the line with most length, and it was about 4000 characters. With google i found several... (4 Replies)
Discussion started by: p1cm1n
4 Replies

8. UNIX for Dummies Questions & Answers

Simple Problems to Solve!

Hi, I'm pretty poor at using UNIX but I'm learning. Please help me with these simple problems! Much appreciated! 1. I've changed my shell from bash to csh but I prefer bash. How do I change back? I've tried using chsh -s but it's not working! 2. I'm trying to download TopCat. I've done... (2 Replies)
Discussion started by: SimonWhite
2 Replies

9. Shell Programming and Scripting

simple problems in awk

Dear All, I have the following awk script. #!/bin/bash sh stdev.cmd data.file | awk '{print $2}' > out.data read d < out.data echo $d awk '{print $1,$2- $f}' new > newz The script runs "stdev.cmd" and output a file "out.data" and the value of the... (2 Replies)
Discussion started by: Yacob_123
2 Replies

10. Shell Programming and Scripting

Simple loop using for

Dear experts, I am writing a bash script. At some point of the program I need to have 'for' loop. For simplicity I tried with some other simple code. The format of the loop is given below. k=51 m=55 for j in {$k..$m};do w=$(($j+2)) z=$(($j+9)) echo "$w, $z" done But my... (4 Replies)
Discussion started by: vjramana
4 Replies
ECHO(1) 						    BSD General Commands Manual 						   ECHO(1)

NAME
echo -- write arguments to the standard output SYNOPSIS
echo [-n] [string ...] DESCRIPTION
The echo utility writes any specified operands, separated by single blank (' ') characters and followed by a newline (' ') character, to the standard output. The following option is available: -n Do not print the trailing newline character. This may also be achieved by appending 'c' to the end of the string, as is done by iBCS2 compatible systems. Note that this option as well as the effect of 'c' are implementation-defined in IEEE Std 1003.1-2001 (``POSIX.1'') as amended by Cor. 1-2002. Applications aiming for maximum portability are strongly encouraged to use printf(1) to sup- press the newline character. Some shells may provide a builtin echo command which is similar or identical to this utility. Most notably, the builtin echo in sh(1) does not accept the -n option. Consult the builtin(1) manual page. EXIT STATUS
The echo utility exits 0 on success, and >0 if an error occurs. SEE ALSO
builtin(1), csh(1), printf(1), sh(1) STANDARDS
The echo utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'') as amended by Cor. 1-2002. BSD
April 12, 2003 BSD
All times are GMT -4. The time now is 06:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy