ls wildcard output to a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ls wildcard output to a variable
# 1  
Old 09-11-2009
ls wildcard output to a variable

I am new to shell programming, i have a requierement to assign a file name into a variable.
for ex:
the file name are below
603_2009_09_24_34.csv
702_2009_10_25_10.csv

for ex: i need to get the file 603_2009_09_24_34.csv but first 3 didgits are fixed but rest of the digits are not
below is the correct systax.?
VAR=`ls '603' * `
# 2  
Old 09-11-2009
Code:
VAR=$(ls -1 603*)

or
Code:
VAR=`ls -1 603*`

# 3  
Old 09-11-2009
thank you for you reply.

shall i assisn this 603 in some value i.e value='603'

VAR=`ls -1 $value*`

will work above one.?
# 4  
Old 09-11-2009
Both will work..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

2. Shell Programming and Scripting

Why output nothing to variable?

root@SDP_Gaming_Socketed_GT3-1:/# rngd -r /dev/urandom -v Available entropy sources: Intel/AMD hardware rng DRNG root@SDP_Gaming_Socketed_GT3-1:/# x=`rngd -r /dev/urandom -v` root@SDP_Gaming_Socketed_GT3-1:/# echo "$x" #get nothing root@SDP_Gaming_Socketed_GT3-1:/# x=`eval rngd -r... (6 Replies)
Discussion started by: yanglei_fage
6 Replies

3. Shell Programming and Scripting

Getting a variable and output to use later on in script

Hi Guys! I'm trying to get this script going but running into a little issue. not sure what is going on. basicly how i'm writing this script is to ask you what is the password you want to be encrypted, then ask you what the user id is, takes that info run's the encryption script with the... (2 Replies)
Discussion started by: vpundit
2 Replies

4. Shell Programming and Scripting

using awk for setting variable but change the output of this variable within awk

Hi all, Hope someone can help me out here. I have this BASH script (see below) My problem lies with the variable path. The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level. The... (6 Replies)
Discussion started by: Cowardly
6 Replies

5. Shell Programming and Scripting

Passing a wildcard in a variable

Hi There I am new to scripting and require some assistance please. I am trying to define a variable with a wildcard in a shell script (.ksh) that will be run on AIX 5300-10. The variable I am trying is: FILES=LLA_*.CSVWhen I run the following section of the script: scp... (2 Replies)
Discussion started by: jimbojames
2 Replies

6. Shell Programming and Scripting

Passing wildcard parameters to find via a variable

I have a script to fix permissions which is made up of blocks like: FS_ROOT=/home/shared/Photos FS_EXCLUDE=( \( -path */.webviews -o -path */.thumbnails \) -prune -o ) find $FS_ROOT ${FS_EXCLUDE} -type d -not -perm 2770 -exec chmod 2770 "{}" \; That fragment works as expected, but no matter... (3 Replies)
Discussion started by: mij
3 Replies

7. UNIX for Dummies Questions & Answers

Output into a Variable

i was wondering is there anyway to take the output of a command and put it into a variable?? what i need to to is only take a certain part of the output that lies between <"data needed "> ---------- Post updated at 09:39 PM ---------- Previous update was at 09:38 PM ---------- and place... (6 Replies)
Discussion started by: jmorey
6 Replies

8. Shell Programming and Scripting

How to maintain wildcard array variable

Hi all, I have this scenario where:- The file that I want to save its name into array df is my.08120323.trx which is located in the dir as below: $ pwd /u01/abc/def/SRC_datafiles $ ls *trx my.08120323.trx $ df=*"trx" ##keeping the filename my.08120323.trx into df $... (2 Replies)
Discussion started by: luna_soleil
2 Replies

9. Shell Programming and Scripting

Assigning output to a variable

I am new to unix shell scripting. I was trying to convert each lines in a file to upper case. I know how to convert the whole file. But here i have to do line by line. I am getting it in the below mentioned script #!/bin/bash #converting lower to upper in a file #tr "" "" <file1... (3 Replies)
Discussion started by: jpmena
3 Replies

10. UNIX for Dummies Questions & Answers

Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days... The structure of the paths are like this: /home/domains/www.domain2.com/tgp/ /home/domains/www.domain3.com/tgp/... (1 Reply)
Discussion started by: Neko
1 Replies
Login or Register to Ask a Question