Change everything in a file that maps to {module::name.filetype} to _modules/name/applicat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change everything in a file that maps to {module::name.filetype} to _modules/name/applicat
# 1  
Old 07-26-2013
Change everything in a file that maps to {module::name.filetype} to _modules/name/applicat

Code:
path      = content.txt
filename  = application
directory = _modules
 
define create
	$(eval from := $(shell echo $$1)) \
	$(eval to   := $(shell echo $$2)) \
	sed -i '' 's/$(from)/$(to)/g' content.txt
endef
 
all:
	clear
 
	$(eval modules := $(shell egrep -o "{module[^ ]+\}" $(path)))
 
	@for m in $(modules); do \
		$(call create, $$m, \
			$$m \
			| sed 's/{module\([^ ]*\).*}/\1/' \
			| sed 's/\./\/$(filename)\./g' \
			| sed 's/\::/\$(directory)\//g' \
		); \
	done

I'm getting this error:
sed: first RE may not be empty

I think the reason for it is because I can not use shell script inside of a for loop because $$1 is returning null.
Anyone have any idea how to solve this issue?
# 2  
Old 07-27-2013
The error is
Code:
sed -i '' ...

an empty sed script.
And why -i? Is it your intention to modify its input file (content.txt)?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add unique identifier from file to filetype in directory

I am trying to add a unique identifier to two file extensions .bam and .vcf in a directory located at /home/cmccabe/Desktop/index/R_2016_09_21_14_01_15_user_S5-00580-9-Medexome. The identifier is in $2 of the input file. What the code below is attempting to do is strip off the last portion... (21 Replies)
Discussion started by: cmccabe
21 Replies

2. UNIX for Advanced & Expert Users

File command return wrong filetype while file holds group separator char.

hi, I am trying to get the FileType using the File command. I have one file, which holds Group separator along with ASCII character. It's a Text file. But when I ran the File command the FileType is coming as "data". It should be "ASCII, Text file". Is the latest version of File... (6 Replies)
Discussion started by: Arpitak29
6 Replies

3. Shell Programming and Scripting

Moving multiple filetype in a single loop

Hi, I am using the below code to move *.sh files to another directory. use File::Copy qw(move); while(<C:/Users/pandeesh/Desktop/*.sh>) { move $_,"C:/Users/pandeesh/Desktop/Projects"; } My requirement is i want to move *.sh,*.txt,*.xlsx,*.doc,*.pdf and *.epub files to the specified... (2 Replies)
Discussion started by: pandeesh
2 Replies

4. Shell Programming and Scripting

Converting DOS filetype to UNIX

Hello folks I am working on a project that requires me to write a script that operates on a bunch of text files. When I try less file.txt I see a bunch of ^M's everywhere. Some Googling tells me that this is because the files have a DOS fileformat and found the following fixes: sed 's/^M$//'... (5 Replies)
Discussion started by: ksk
5 Replies

5. UNIX for Dummies Questions & Answers

How to move files based on filetype and time created?

Hi, I'm trying to improve my Unix skills and I'm wondering what is the best way to move some files based on filetype and attributes like time created? For instance, lets suppose I have a directory with many different files in it and I'd like to move all the jpgs that were created between May... (6 Replies)
Discussion started by: LuckyTommy
6 Replies

6. Homework & Coursework Questions

Grep for filetype starting with letter p

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Which files in /usr/bin whose names begin with “p” are python scripts? Store the numbered results in... (3 Replies)
Discussion started by: alindner
3 Replies

7. Shell Programming and Scripting

Create Repositories with the *.dump filetype

I've a bunch of repository dumps that I need to include in my shell script to restore from the dump, but first I need to create the repositories first. How do I extract the names of the repository and removing the *.dump for use of the following line? bash-3.00$ ls andromeda.dump alias.dump... (4 Replies)
Discussion started by: lynxlee
4 Replies

8. Shell Programming and Scripting

Find file that maps to a listening port

On my VPS server I have a port that is open and is listening for a 'status' command when you connect to it to like so... $ telnet host 1900 Trying host... Connected to host. Escape character is '^]'. status QMAIL;OK APACHE;OK HTTPD;OK CRON;OK Wondering if what command I can attempt... (2 Replies)
Discussion started by: phpfreak
2 Replies

9. Linux

How to convert Linux Kernel built-in module into a loadable module

Hi all, I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/. I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies

10. Linux

mount filetype error

Hello, I am trying to mount an external USB drive connected to a SnapServer 410 ( a network file server running a linux OS called Guardian OS). THanks to some articles on the the web, I found that I needed to use the following command: > mount -t vfat /dev/sde /mnt/usbext ... (7 Replies)
Discussion started by: drmoque
7 Replies
Login or Register to Ask a Question