Print continues names


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print continues names
# 1  
Old 03-16-2014
Print continues names

Gents,

I will like to print continues names according to a range of numbers

example
first number
1000
last number
1005

I would like to get the following result
tape1000 tape1001 tape 1002 tape1003 tape1004 tape1005.

Thanks for your support.
# 2  
Old 03-16-2014
Try:
Code:
for i in {1000..1005}; do printf "tape$i "; done; echo

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 03-16-2014
Try like this, if interested in awk

Code:
$ awk -vstart='1000' -vend='1005' -vname='tape' 'BEGIN{for(i=start;i<=end;i++) s = s ? s OFS name i : name i;print s}'

tape1000 tape1001 tape1002 tape1003 tape1004 tape1005

---------- Post updated at 02:39 AM ---------- Previous update was at 02:30 AM ----------

Or like this

Code:
$ echo $(printf 'test%s ' {1000..1005})
test1000 test1001 test1002 test1003 test1004 test1005

$ printf 'test%s ' {1000..1005};printf "\n"
test1000 test1001 test1002 test1003 test1004 test1005

---------- Post updated at 02:40 AM ---------- Previous update was at 02:39 AM ----------
This User Gave Thanks to Akshay Hegde For This Post:
# 4  
Old 03-16-2014
Bash:
Code:
echo tape{1000..1005}

These 2 Users Gave Thanks to Yoda For This Post:
# 5  
Old 03-16-2014
Quote:
Originally Posted by Akshay Hegde
Try like this, if interested in awk

Code:
$ awk -vstart='1000' -vend='1005' -vname='tape' 'BEGIN{for(i=start;i<=end;i++) s = s ? s OFS name i : name i;print s}'

tape1000 tape1001 tape1002 tape1003 tape1004 tape1005

---------- Post updated at 02:39 AM ---------- Previous update was at 02:30 AM ----------

Or like this

$ printf 'test%s ' {1000..1005};printf "\n"
test1000 test1001 test1002 test1003 test1004 test1005
[/CODE]---------- Post updated at 02:40 AM ---------- Previous update was at 02:39 AM ----------

[CODE]$ echo $(printf 'test%s ' {1000..1005})
test1000 test1001 test1002 test1003 test1004 test1005

I did something like this
Code:
     printf "Please enter the tapes numbers.\n"
      printf "\n"
             read -p "First tape: " ftape
      printf "\n"
             read -p "Last tape : " ltape

awk -vstart=$ftape -vend=$ltape -vname='tape' 'BEGIN{for(i=start;i<=end;i++) s = s ? s OFS name i : name i;print "tar cvf /dev/st0 " s}'

Thanks for your helpSmilie

---------- Post updated at 03:54 PM ---------- Previous update was at 03:51 PM ----------
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for names in one list in another and print results

Hi All , New to the Bash / Shell programming world and looking for some help I have two files 1: Contains a list of names : eg STEVE BOB CRAIG 2: Contains information with those included names but also others that are not in the list (1 Reply)
Discussion started by: Lonerg550
1 Replies

2. Shell Programming and Scripting

Print the output with different file names

I have a python script that gives output called test.png. By using the following command I run the script every 2 seconds. What is the easiest way to save the output as follows ( test.png (1st output), tes1.png (second output), tes2.png ....) Command I i use while sleep 2; do python... (1 Reply)
Discussion started by: quincyjones
1 Replies

3. UNIX for Dummies Questions & Answers

awk question - print columns with names

I found this command and would like to know what it means: gawk 'NR==1{for(i=1;i<=NF;i++)if($i~/FE/)f=i}{for(i=0;i<n;i++)printf"%s%s",i?" ":"",$f;print""}' It seems to mean if the row =1 assign i to that row, and then if FE is in the top row /column then increment and print the row. I am... (2 Replies)
Discussion started by: newbie2010
2 Replies

4. UNIX for Advanced & Expert Users

Find 2 occurrences of a word and print file names

I was thinking something like this but it always gets rid of the file location. grep -roh base. | wc -l find . -type f -exec grep -o base {} \; | wc -l Would this be a job for awk? Would I need to store the file locations in an array? (3 Replies)
Discussion started by: cokedude
3 Replies

5. Shell Programming and Scripting

Print file names in a loop

OS : RHEL 6.1 Shell : Bash I have lots of files in /tmp/stage directory as show below. Using a loop, I need to print all the filenames in this directory except those ending with a number. How can I do this ? # pwd /tmp/stage # # # ls -l * -rw-r--r--. 1 root root 0 Oct 7 18:38 stmt1... (2 Replies)
Discussion started by: kraljic
2 Replies

6. Shell Programming and Scripting

Print unique names in a specific column using awk

Is it possible to modify file like this. 1. Remove all the duplicate names in a define column i.e 4th col 2. Count the no.of unique names separated by ";" and print as a 5th col thanx in advance!! Q input c1 30 3 Eh2 c10 96 3 Frp c41 396 3 Ua5;Lop;Kol;Kol c62 2 30 Fmp;Fmp;Fmp ... (5 Replies)
Discussion started by: quincyjones
5 Replies

7. Shell Programming and Scripting

Print numbers along with file names.

Hi All, I have some thousand files with names like 1.syl, 2.syl, 5.syl etc. These files contain one sentence each. I want to store all those sentences along with the file ID that is 1, 2, 5 with the sentences they contain. For example, 1.syl has this is a test line 2.syl has ... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

8. Shell Programming and Scripting

Print column names along with values from SQL

Hi, Can anyone tell me how to print the column name anong with the value from the table in shell script e.g #!/bin/ksh var=`sqlplus scott/tiger << -e set heading off feedback off select * from emp; quit; e` echo $var My output should be; ... (5 Replies)
Discussion started by: thana
5 Replies

9. Shell Programming and Scripting

How to print the files names that being searched

Hello all Im doing search in jar files using this oneLiener : find . -name "*.jar" -print -exec jar -tvf {} \; | grep -n \/someClassName.class but I also will like to see the jar file names that the grep succeed the search What I need to add to this command so it will give the file names? (2 Replies)
Discussion started by: umen
2 Replies

10. UNIX for Dummies Questions & Answers

Need to print file names in a certain date range using ls

I need to list only file names of a specific date from the command ls -lt. :confused: (2 Replies)
Discussion started by: Shamwari
2 Replies
Login or Register to Ask a Question