Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Modify file with directory structure details

Posted on 2011-09-06
3
Medium Priority
?
246 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

636 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