Using awk to create files based on a variable name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using awk to create files based on a variable name
Prev   Next
# 1  
Old 11-14-2009
Using awk to create files based on a variable name

Hey all,
I am parsing a file which have records containing one of a number of files names:
".psd", ".cr2", ".crw" , ".cr", ".xi", ".jpg", ".xif" etc
Somewhere on each line there is a value "Namex.psd" "Namex.crw" etc. The position of this name is highly variable
I need to output all the ".psd" records into a single file called PSD. Each record in the file would be named "Namex".
Ultimately I would have 8 or 9 file names containing 15 thousand records.

The question is how do I output data into records based on the contents of the data?

Your help would be greatly appreciated.

---------- Post updated at 11:30 AM ---------- Previous update was at 11:23 AM ----------

One clarification.
I meant each value in the output file would be Namex.
example
an input record containing "picture_001.psd would be output to a filename called "PSD" and it's value would be "picture_001"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to create subdirectory based on match between two files

In the below awk I am trying to mkdir based of an exact match between file2 line starting with R_2019.... and file1 line starting with R_2019. When a match is found there is a folder located at /home/cmccabe/run with the same name as the match where each $2 in file1 is a new subdirectory in that... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. UNIX for Beginners Questions & Answers

Create file based on data from two other files

I have looked through several threads regarding merging files with awk and attempted using join however have been unsuccessful likely as I do not fully understand awk. What I am attempting is to take a csv file which could be between 1 and 15,000 lines with 5 colums and another csv file that will... (4 Replies)
Discussion started by: cdubu2
4 Replies

3. Shell Programming and Scripting

Create multiple files from single file based on row separator

Hello , Can anyone please help me to solve the below - Input.txt source table abc col1 char col2 number source table bcd col1 date col2 char output should be 2 files based on the row separator "source table" abc.txt col1 char (6 Replies)
Discussion started by: Pratik4891
6 Replies

4. Shell Programming and Scripting

awk Parse And Create Multiple Files Based on Field Value

Hello: I am working parsing a large input file which will be broken down into multiples based on the second field in the file, in this case: STORE. The idea is to create each file with the corresponding store number, for example: Report_$STORENUM_$DATETIMESTAMP , and obtaining the... (7 Replies)
Discussion started by: ec012
7 Replies

5. Shell Programming and Scripting

bash script to create txt files based on timestamp

Hi , please guide me for a bash script that will create a txt files and the name of the txt files will be as of timestamp so that each file name will be different from other and these files will be get created say after every 10 minutes in a folder(/home/p2000/sxs137), please guide me how would... (1 Reply)
Discussion started by: nks342
1 Replies

6. Shell Programming and Scripting

Create files based on second column of a file

Hi All, I have a file which looks like this: 234422 1 .00222 323232 1 3232 32323 1 0.00222 1234 2 1211 2332 2 0.9 233 3 0.883 123 3 45 As you can see, the second column of the file is already sorted which I did using sort command. Now, I want to create files based on the second... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Shell Programming and Scripting

Awk script to create new file based on previous line

Need help creating a script that does the following: Sort a file Compare the previous line "last field" with current line "last field" If they are the same, print output to a file If they are different print output to a new file The script should keep creating new files if the previous... (5 Replies)
Discussion started by: Muga801
5 Replies

8. UNIX for Advanced & Expert Users

Create a file based on multiple files

Hey everyone. I am trying to figure out a way to create a file that will be renamed based off of one of multiple files. For example, if I have 3 files (cat.ctl, dog.ctl, and bird.ctl) that gets placed on to an ftp site I want to create a single file called new.cat.ctl, new.dog.ctl, etc for each... (3 Replies)
Discussion started by: coach5779
3 Replies

9. Shell Programming and Scripting

create diffrent files based on other file and parameters list

I would like ot create shell script/ bash to create diffrent files based on a file and parameters list. Here is the detail example: I have a textfile and four static parameter files (having ‘?'). mainfile.txt has below records (this count may be more than 50) A200001 A200101 B200001... (9 Replies)
Discussion started by: raghav525
9 Replies

10. Shell Programming and Scripting

create variable name based on another variable's value

Hello, I am needing to create a variable and assign it a value based on the value of a previosly defined variable... I am using KSH.. Example: VAR1=COMPUTER1 I need another variable like ${VAR1}_FLAG="Y", so it would actually be COMPUTER1_FLAG="Y". I will be looping through many values in... (2 Replies)
Discussion started by: benefactr
2 Replies
Login or Register to Ask a Question
layerutil(1)						    BSD General Commands Manual 					      layerutil(1)

NAME
layerutil create compiled layered image stack SYNOPSIS
layerutil [-Vlhogspf] inputfile DESCRIPTION
Creates a compiled layered image stack (lcr) file from a layered input file source, such as an lsr or suitably structured Photoshop (psd) file. If the psd file's basename ends with @Yx Y will be treated as the scale factor of the psd file. If gpu compression is not specified then lossy compression is used. OPTIONS
The following options are available: -c Convert to lcr format. -f s, --flattened-image Saves the flattened image as a jpeg to the output path given by the -o flag. if the output filename doesn't end with .jpeg or .jpg then the file extension that was given will be removed and jpeg will get added. If the file that gets written out is a JPEG image, the resulting image will be compressed with the default compression options. -g s, --gpu-compression=s Sets program to use gpu optimized compression. You can choose either best or smallest. GPU Compression is only supported on iOS 10.0/AppleTV 10.0 or greater. -l n, --lossy-compression=n Set the lossy compression factor used for image content to a value between 0 and 1.0, default is 0.75. The smaller the value, the smaller the compressed file size. A value of 1.0 creates a lossless image. -s n, --scale=v Used to specify the scale factor used in the generated lcr file. When used with a PSD file it indicates the scale factor of the PSD file. When used with an LSR file indicates which scale factor of images should be kept. If scale is not specified 1 is assumed. -p n, --display-gamut=v v can be one of srgb/p3. Selecting p3 processes the image and if it contains wide gamut data will be treated as such. -g s, --palette-image Turn on palette image compression (Defaults to off). -o, --output Output file name. If you are converting an input lsr/psd file then if no output file is given, the basename of the input file is used as the output file name with an appended .lcr extension. unless you are -h, --help Prints out usage information. -V, --version Prints out version information. Darwin November 13, 2017 Darwin