Sponsored Content
Top Forums Shell Programming and Scripting Truncate multiple file extensions Post 302133544 by summer_cherry on Friday 24th of August 2007 01:06:53 AM
Old 08-24-2007
!!!!!!!!!!!!

Hi try this one:

Code:
echo "number"
read num
who | nawk -v n=$num 'BEGIN{
str="file"
for (i=1;i<=n;i++)
str=sprintf("%s%s",str,".txt")
}
END{
print str
printf("%stxt\n",substr(str,1,index(str,".")))
}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find -regex: matching multiple extensions

I want to use find to locate files with two different extensions, and run a grep on the results. The closest I have gotten is incredibly slow and ugly: for i in `ls -laR|egrep -e '(.js|.css)'`; do find . -name $i -print|xargs grep -H searchBg; done; This method makes my eyes bleed. Help! ;) ... (2 Replies)
Discussion started by: r0sc0
2 Replies

2. Shell Programming and Scripting

Truncate File contain

I have one file which first line is blank and second line has some data. $cat filename output: 30-MAY-07 I want to store 30-MAY-07 value in one variable. for that I wrote var="`head -2 filename`" It will give that result but I want to truncate the first line which is blank. plz help. (2 Replies)
Discussion started by: rinku
2 Replies

3. UNIX for Dummies Questions & Answers

Truncate last <n> characters from a file

I am trying to concatenate 2 files, but before concatenation, I would like to strip off the final character from the first file. The final character is a form feed (ascii 012 / hex 0C) and there will be an unknown number of these characters in the file. It is only the very last one which I want... (1 Reply)
Discussion started by: Gwailo88
1 Replies

4. Shell Programming and Scripting

Stripping out extensions when file has multiple dots in name

I posted this already in another thread, but was told that I should create a seperate thread for the following question: How do I strip the extension when the delimiter might occur multiple times in the filename? For example: I have 2 files as input for my script. test.extension... (8 Replies)
Discussion started by: Nemelis
8 Replies

5. Shell Programming and Scripting

Creating multiple extensions

Friends I want to automat sending a letter to different persons whose directories are named as 001, 002, 003, 004. To push the same letter to all these directories, I need to name the letter as letter.001, letter.002 like that. Is there any method whereby I get the extension of this letter... (2 Replies)
Discussion started by: chssastry
2 Replies

6. UNIX for Dummies Questions & Answers

changing extensions for multiple files at once

I copied some files to another folder, and I want to change them from .doc extensions to .txt extensions. I tried using the cp and mv commands, but it didn't work. Is it possible to change file extensions with these commands, and if so how do I do it? I tried using the * wildcard (say cp *.doc... (1 Reply)
Discussion started by: Straitsfan
1 Replies

7. Shell Programming and Scripting

Truncate file name to 40 characters

Hello all. I would like to make a script (or two shell scripts) that will do the following. I need the maximum file name and directory name to be 38 characters long. As well, if shortening the file name ends up making all of the files in that directory have the same name, then I would like... (9 Replies)
Discussion started by: marcozd
9 Replies

8. UNIX for Dummies Questions & Answers

recover the truncate file

hi All, how to recover the truncate file in unix. Thanks!:wall: (2 Replies)
Discussion started by: krbala1985
2 Replies

9. Shell Programming and Scripting

Replacing multiple extensions

HI, I have some csv files with mutiple extensions, I want to remove all the extensions and keep only the .csv extension. anybody can suggest me how to do this. source files 1.txt.csv.txt.csv.csv.txt.csv 2.csv.txt.csv.txt.csv.txt target 1.csv 2.csv --Wang (1 Reply)
Discussion started by: wangkc
1 Replies

10. Shell Programming and Scripting

List directory name (only once) after multiple file extensions found

Here is a simplified example of my problem. Say I have the following 3 sub-directories; ./folder1 A.txt A.sh ./folder2 B.txt ./folder3 C.txt C.sh I would like to list the directory names which contain both '.txt' & '.sh' type extensions. I have came up with the following code;... (8 Replies)
Discussion started by: mmab
8 Replies
DISKTAB(5)						      BSD File Formats Manual							DISKTAB(5)

NAME
disktab -- disk description file SYNOPSIS
#include <disktab.h> DESCRIPTION
disktab is a simple database which describes disk geometries and disk partition characteristics. It is used to initialize the disk label on the disk. The format is patterned after the termcap(5) terminal data base. Entries in disktab consist of a number of `:' separated fields. The first entry for each disk gives the names which are known for the disk, separated by `|' characters. The last name given should be a long name fully identifying the disk. The following list indicates the normal values stored for each disk entry. Name Type Description ty str Type of disk (e.g. removable, winchester) dt str Type of controller (e.g. SMD, ESDI, floppy) ns num Number of sectors per track nt num Number of tracks per cylinder nc num Total number of cylinders on the disk sc num Number of sectors per cylinder, ns*nt default su num Number of sectors per unit, sc*nc default se num Sector size in bytes, DEV_BSIZE default sf bool Controller supports bad144-style bad sector forwarding rm num Rotation speed, rpm, 3600 default sk num Sector skew per track, default 0 cs num Sector skew per cylinder, default 0 hs num Headswitch time, usec, default 0 ts num One-cylinder seek time, usec, default 0 il num Sector interleave (n:1), 1 default d[0-4] num Drive-type-dependent parameters bs num Boot block size, default BBSIZE sb num Superblock size, default SBSIZE ba num Block size for partition `a' (bytes) bd num Block size for partition `d' (bytes) be num Block size for partition `e' (bytes) bf num Block size for partition `f' (bytes) bg num Block size for partition `g' (bytes) bh num Block size for partition `h' (bytes) fa num Fragment size for partition `a' (bytes) fd num Fragment size for partition `d' (bytes) fe num Fragment size for partition `e' (bytes) ff num Fragment size for partition `f' (bytes) fg num Fragment size for partition `g' (bytes) fh num Fragment size for partition `h' (bytes) oa num Offset of partition `a' in sectors ob num Offset of partition `b' in sectors oc num Offset of partition `c' in sectors od num Offset of partition `d' in sectors oe num Offset of partition `e' in sectors of num Offset of partition `f' in sectors og num Offset of partition `g' in sectors oh num Offset of partition `h' in sectors pa num Size of partition `a' in sectors pb num Size of partition `b' in sectors pc num Size of partition `c' in sectors pd num Size of partition `d' in sectors pe num Size of partition `e' in sectors pf num Size of partition `f' in sectors pg num Size of partition `g' in sectors ph num Size of partition `h' in sectors ta str Partition type of partition `a' (4.2BSD filesystem, swap, etc) tb str Partition type of partition `b' tc str Partition type of partition `c' td str Partition type of partition `d' te str Partition type of partition `e' tf str Partition type of partition `f' tg str Partition type of partition `g' th str Partition type of partition `h' FILES
/etc/disktab SEE ALSO
getdiskbyname(3), disklabel(5), disklabel(8), newfs(8) HISTORY
The disktab description file appeared in 4.2BSD. BSD
June 5, 1993 BSD
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy