Sponsored Content
Top Forums Shell Programming and Scripting A simple variable subst is not working Post 302649875 by IMPe on Friday 1st of June 2012 08:02:10 AM
Old 06-01-2012
A simple variable subst is not working

Hi

what i want:
listing files in a special range

Code:
ls -lrt 20120601{05..06}*
 ...
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:51 201206010550
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:01 201206010600
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:11 201206010610
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:21 201206010620
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:31 201206010630
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:41 201206010640
 -rw-rw-r-- 1 imp imp 279  1. Jun 07:51 201206010650



.. setting the command like this, it is working properly.


If i subst one value by a variable or a command...


M=05
ls -lrt 20120601{$M..06}*
"note"
ls: no access to 20120601{05..06}* : cant find file or directory.
.. with the command ..
ls -lrt 20120601{`date +%m`..06}*ls -lrt 20120601{`date --date="9 days ago" +%m`..06}*
ls:
no access to20120601{05..06}*cant find file or directory.

It seems to me, that the brackets are still there ..
A colleague gave me a first hint ..
Code:
ls -lrt `eval echo 20120601{$M..06}*`



Can someone help me, how to do it... more elegant and especially with the subst. commands.

Thanks in advance
IMPe

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command param subst to reg expression

I want to find out Row which starts with, the user specified details to a script. In general I know what command to be given. awk '$0~/^Vi/' BReject But I need to pass on $1 param of command line at the place of 'Vi'. I tried with -v subst=$1 awk -v subst=$1 '$0~/^subst/' BReject But it... (5 Replies)
Discussion started by: videsh77
5 Replies

2. Shell Programming and Scripting

Why this simple script, is not working ?

Hi everybody I want to create 20 file using simple script - listed bellow-. But the script doesn't work. I hope anyone guide me to correct this script ---------------- The script integer number=01 until (($number==21)) do >TELE-LOG-$number number=$number+01 echo $number done exit... (4 Replies)
Discussion started by: so_friendly
4 Replies

3. Shell Programming and Scripting

simple perl script not working

why won't below work? I am trying to see a)sipfile has username of the system. b)it will read the sipfile and do a grep function against the /etc/passwd c)it will save that output to /tmp/result.. but my script is just hanging... #!/usr/bin/perl -w open(SIPFILE, "</tmp/sipfile") ... (4 Replies)
Discussion started by: hankooknara
4 Replies

4. Shell Programming and Scripting

assign subst|grep|sed command result to a variable

Hi, I'm quite new to scripting and I want to modify following line of an existing script: MYVAR=`subst |grep 'L:\\\:' | sed -e 's/.*\\\//'`; What I have to do is to use the content of a variable instead of the constant expression 'L:\\\:' as the grep string to be matched. Assuming I already... (5 Replies)
Discussion started by: snowbiker99
5 Replies

5. Shell Programming and Scripting

simple grep is not working for me

Hi, On the log Netscape log, I need to grep for 500 error. I am doing that but I also get 1500 in that same log. cat access |grep "500" Results: "GET /css/RBR.css HTTP/1.1" 200 15000 304 - - - 399 639 523 164 0 This not what I need... Please advice. (4 Replies)
Discussion started by: samnyc
4 Replies

6. Shell Programming and Scripting

Simple BASH script not working?

So I need a script that does the following: If a certain user is logged in Run `command` Else Echo “incorrect user” This is my first stab...which doesn't work: #!/bin/bash X="user=`ls -l /dev/console | cut -d " " -f 4`" Y="foobar" echo $X echo $Y (4 Replies)
Discussion started by: doubleminus
4 Replies

7. Shell Programming and Scripting

Cut determinate values amb subst for ;

Hello I have a output file that contains the next info: host_name LET-234-WDFD-2 address 10.11.0.62 host_name XWERWE-234-WEDF-EMEEH-GIDF-3 address 10.11.32.48 host_name DFG-745-WE-EMEEEH-GIDF-4 address 10.11.32.176 host_name ... (6 Replies)
Discussion started by: capilla
6 Replies

8. Shell Programming and Scripting

Using make subst

I have a string of source files ENBL_PX11_LIBSRC = pltsub.f xpltlib.f xbuplot.cI want to replace .f and .c with .o to get ENBL_PX11_LIBOBJ = pltsub.o xpltlib.o xbuplot.o However I am having trouble doing this with subst. (5 Replies)
Discussion started by: kristinu
5 Replies

9. UNIX for Dummies Questions & Answers

A simple join, but nothing is working out for me

Guys, I want to join two files. You might have seen this many times. I just don't get the desired output. Searching the forum, No proper links :( Input: File1 test1 test2 test3 File2 is bad is not bad Output Needed: test1 is bad test2 is bad (4 Replies)
Discussion started by: PikK45
4 Replies

10. Shell Programming and Scripting

Simple Variable substitution in ksh not working

Hi Gurus, Not able to catch what's going wrong here. I just want to get output as "tree". server:/mk/app/nexapp $ echo $SHELL /usr/bin/ksh server:/mk/app/nexapp $ export db_name1="tree" server:/mk/app/nexapp $ export i=1 1st try: server:/mk/app/nexapp $ echo $(db_name$i) ksh: db_name1: ... (3 Replies)
Discussion started by: mukesh.lalwani
3 Replies
All times are GMT -4. The time now is 10:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy