|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Working with file-names
Hello forum, I am new to shellscripting. My first goal is to write a script that verifies that for each file in one path there is an associated one in another path. The association is deviated by a distinct 'part' of the filename(s). Therefore I wanted to work with substitution. Here is what I have so far: Code:
for i in /my/source/path/*
do
var=basename $i
echo ${var//cutme/""}
doneI expected to put every filename reduced by the string 'cutme' to stdout. But it will tell me it has not sufficient privileges. I think it tries to rename the actual filename, but I just want to work with a 'copy'. How can I work with filenames without actually changing it? regards |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Try: Code:
var=$(basename $i) or Code:
var=${i##*/} |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
It worked. Thank you Scrutinizer. So Code:
var=$(some) means copy the value to a new variable? |
|
#4
|
||||
|
||||
|
This is called command substitution.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Split File by Pattern with File Names in Source File... Awk? | cul8er | Shell Programming and Scripting | 2 | 11-25-2011 01:38 PM |
| How to split a data file into separate files with the file names depending upon a column's value? | nithins007 | Shell Programming and Scripting | 2 | 09-25-2011 07:38 AM |
| Searching for file names in a directory while ignoring certain file names | 2reperry | Shell Programming and Scripting | 2 | 12-13-2009 09:16 PM |
| Working with folder names | ricksj | UNIX for Dummies Questions & Answers | 6 | 01-23-2009 11:01 AM |
| Reading file names from a file and executing the relative file from shell script | anushilrai | Shell Programming and Scripting | 4 | 03-10-2006 04:25 AM |
|
|