03-12-2007
SED To insert Directory Contents to file
I am on a HP-UX machine I have a directory called "/u01/blobs" and the files look like this:
ls -1
7398
7399
7400
I need to produce a comma delimited file with the following format:
filename,location/filename
i.e:
7398,/u01/blobs/7398
7399,/u01/blobs/7399
7400,/u01/blobs/7400
What I have so far is:
#!/bin/ksh
FILE_DIR=/u01/blobs
INFILE=a.txt
INFILE2=b.txt
INFILE3=c.txt
if [[ -a $INFILE ]]; then
rm $INFILE
fi
ls -1 $FILE_DIR > $INFILE
cat $INFILE | sed 's/$/,\/u01\/blobs\//w '${INFILE2} > /dev/null
But this just gives me the filename and directory.
It seams like a simple task but it is giving me a SEDache.
Regards,
NomDeGuerre
10 More Discussions You Might Find Interesting
1. Programming
Dear Friends,
I m beginner unix programmer. I want to know, how to read and write directory or file contents in c++ ? (3 Replies)
Discussion started by: namrata5
3 Replies
2. Shell Programming and Scripting
Hi,
I have a set of files stored in a single directory that I use to set parameters for a physics code, and I would like to streamline the process of updating them all when I change a parameter. For instance, if the files are called A2000p300ini, A2000p300sub, A2000p300run, and the text in each... (3 Replies)
Discussion started by: BlueChris
3 Replies
3. UNIX for Dummies Questions & Answers
Hello,
Here is what I am trying to accomplish.
I am going to have one directory in which there will be files of varying types (Excel, Word, PPT, and possible others), and I need to be able to be bundle however many files there are in there together in to one file to be used as an e-mail... (3 Replies)
Discussion started by: rip73
3 Replies
4. Shell Programming and Scripting
I'm looking to write a script that will check the contents of a directory, and if any files exist in that directory copy them to a temporary folder. The target files are only resident for a few seconds, so I think the script needs to be running constantly.
Any pointers would be really... (3 Replies)
Discussion started by: danceofillusion
3 Replies
5. Shell Programming and Scripting
I'm trying to write a small shell script/command to insert the contents of one file into another file at a position marked with a given text string. It's not necessarily at the top or bottom of the file so I can't just use cat to cat the files together.
I think probably sed with the r option is... (5 Replies)
Discussion started by: shaun29
5 Replies
6. Shell Programming and Scripting
We have 2 file XML files - FILE1.XML and FILE2.xml - we need copy the contents of FILE1.XML and replace in FILE2.xml pattern "<assignedAttributeList></assignedAttributeList>"
FILE1.XML
1. <itemList>
2. <item type="Manufactured">
3. <resourceCode>431048</resourceCode>
4. ... (0 Replies)
Discussion started by: balrajg
0 Replies
7. UNIX for Dummies Questions & Answers
Hi guys, I am a newbie here :wall:
I need a script that can search for a file in a directory and copy the contents of that file in a new file.
Please help me. :confused: Thanks in advance~ (6 Replies)
Discussion started by: zel2zel
6 Replies
8. Shell Programming and Scripting
Hi,
I have a unix file with the below structure -
CustId1 CustName1 CustPhn1 /u/home/xmldata/A000001
CustId2 CustName2 CustPhn2 /u/home/xmldata/A000002
CustId3 CustName3 CustPhn3 /u/home/xmldata/A000003
Then I have another unix directory /u/home/xmldata
This directory has... (3 Replies)
Discussion started by: Simanto
3 Replies
9. Shell Programming and Scripting
Hi,
I would like to know how, using sed, be able to insert contents of file2 in file1 after say the second occurrence of a given string? e.g.
> cat file1
banana
apple
orange
apple
banana
pear
tangerine
apple
> cat file2
I don't like apples
What would be the sed command to insert... (5 Replies)
Discussion started by: dimocn
5 Replies
10. UNIX for Beginners Questions & Answers
In the below there are two generic .vcf files (genome.S1.vcf and genome.S2.vcf) in a directory. There wont always be two genaric files but I am trying to use bash to rename each of these generic files with specfic text (unique identifier) within in each .vcf. The text will always be different, but... (11 Replies)
Discussion started by: cmccabe
11 Replies
LEARN ABOUT PLAN9
sccs-comb
sccs-comb(1) User Commands sccs-comb(1)
NAME
sccs-comb, comb - combine SCCS deltas
SYNOPSIS
/usr/ccs/bin/comb [-os] [-csid-list] [-psid] s.filename...
DESCRIPTION
comb generates a shell script (see sh(1)) that you can use to reconstruct the indicated s.files. This script is written to the standard
output.
If a directory name is used in place of the s.filename argument, the comb command applies to all s.files in that directory. Unreadable
s.files produce an error; processing continues with the next file (if any). The use of `-' as the s.filename argument indicates that the
names of files are to be read from the standard input, one s.file per line.
If no options are specified, comb preserves only the most recent (leaf) delta in a branch, and the minimal number of ancestors needed to
preserve the history.
OPTIONS
The following options are supported:
-o For each `get -e' generated, access the reconstructed file at the release of the delta to be created. Otherwise, the recon-
structed file is accessed at the most recent ancestor. The use of -o may decrease the size of the reconstructed s.file. It
may also alter the shape of the delta tree of the original file.
-s Generate scripts to gather statistics, rather than combining deltas. When run, the shell scripts report: the file name,
size (in blocks) after combining, original size (also in blocks), and the percentage size change, computed by the formula:
100 * ( original - combined ) / original
This option can be used to calculate the space that will be saved, before actually doing the combining.
-csid-list Include the indicated list of deltas. All other deltas are omitted. sid-list is a comma-separated list of SCCS delta IDs
(SIDs). To specify a range of deltas, use a `-' separator instead of a comma, between two SIDs in the list.
-pSID The SID of the oldest delta to be preserved.
FILES
s.COMB reconstructed SCCS file
comb????? temporary file
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWsprot |
+-----------------------------+-----------------------------+
SEE ALSO
sccs(1), sccs-admin(1), sccs-cdc(1), sccs-delta(1), sccs-help(1), sccs-prs(1), sccs-prt(1), sccs-rmdel(1), sccs-sccsdiff(1), what(1), sccs-
file(4), attributes(5)
DIAGNOSTICS
Use the SCCS help command for explanations (see sccs-help(1)).
BUGS
comb may rearrange the shape of the tree of deltas. It may not save any space; in fact, it is possible for the reconstructed file to actu-
ally be larger than the original.
SunOS 5.10 1 Nov 1999 sccs-comb(1)