Solved

Modify file with directory structure details

Posted on 2011-09-06
3
241 Views
Last Modified: 2012-05-12
I need to take an existing file, an rpm spec file, and insert a list of files at a specific point.  The spec file will have something like this as the demarcation of where the file list needs to be inserted:
%file
The script needs to take a directory and recursively identify all files under that directory and write each file, and its path, on a separate line in the rmp spec file.

What would be the best way to handle this?



0
Comment
Question by:jkavx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:nukeme369
ID: 36493138
#!/bin/bash
workingdir=`pwd`
for filelist in *
do echo $workingdir"/"$filelist >>/tmp/rpmspecfile
done




Fairly self explanatory, but I'll walk through it.

Variable named workingdir is defined with the current directory as its data.
for loop - looping through each file in current directory.  
each file has the following happen:
the $workingdir variable is echoed, with a trailing /  then the current file is written to /tmp/rpmspecfile.

Repeat for every file in the current dir.

0
 
LVL 2

Accepted Solution

by:
nukeme369 earned 500 total points
ID: 36493141
(the above is the script needed to generate the file list - working on the insert at %file part)
0
 

Author Closing Comment

by:jkavx
ID: 36517137
If you can work out the insert at the specific file location piece, please add a comment with the details.  Thx.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question