Hi ,
I've the following file names and i need the part of the file name
The files are like below
and i need to cut the filenames like below
How can i achieve that
Thanks
Hi ,
I've the following file names and i need the part of the file name
The files are like below
and i need to cut the filenames like below
How can i achieve that
Thanks
Assuming that you're using a shell that performs the standard parameter expansions, the following script shows one way to do what you want:
which (if the only two files in the current directory having filenames starting with FN are the two you listed), produces the output:
There's a lot more wrong with that code than the relatively benign useless use of cat.
Why is ls using a long listing if only the filenames are of interest? Why is it doing a reverse mtime sort?
The grep regular expression is incorrect for two reasons: (1) it is unanchored, allowing the FN* to match anywhere and not just at the beginning, and (2) it applies a wildcard to N, so any filename with an F matches.
I haven't tested it, but I don't see how applying sub() to each field of a long ls listing generates the output shown.
I see no reason to bother with a temp file.
I think the shell solutions suggested above are just fine. However, if for some reason ls and grep are preferred:
With sed:
Regards,
Alister
I have this filename "RBD_EXTRACT_a3468_d20131118.tar.gz" and I would like print out the "yyyymmdd" only. I use this command below, but if different command like cut or print....etc. Thanks
ls RBD_EXTRACT* | sed 's/.*\(........\).tar.gz$/\1/' > test.txt (9 Replies)
Hi,
I need a script which do below
I have a filename: TEST2013_09_17_XX_XX_XX.csv
Now script should create a new file with name: XX_XX_XX.csv
Or I should say i need the output as XX_XX_XX.csv
Please help. Mant thanks in advance (3 Replies)
Hi all.. I have several unique files that contain one thing in common, and that is acct#. For all files in the directory, I want to append the 10 characters following the word "ACCOUNT:" to the end of the filename.
for example:
I have file 111_123 that contains ACCOUNT:ABC1234567
The file... (5 Replies)
Hi All,
I have the file & name is "/a/b/c/d/e/xyz.dat"
I need "/a/b/c/d/e/" from the above file name.
I tryning with echo and awk. But it not come. Please help me in this regard.
Thanks & Regards,
Dathu (3 Replies)
I need a small script (sh) to remove in a variable the filename extension.
Example:
f = "testfile.txt"
and I need a $a with "testfile".
Some one a idea? (4 Replies)
Hi all,
I have a list of xml file. I need to split the files to a different files when see the <ko> tag.
The list of filename are
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml
... (3 Replies)
Hi,
I need to cut filename in Linux ksh.
for example file name is c_xxxx_cp_200908175035.zip. I need to get variable with only c_xxxx_cp value. (10 Replies)
I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
-rw-r--r-- 1 fxpbftp fusion 368 Jun 10 08:34 FX_1.11840235236594E12.111234236809956
If I have a long list of files that look like this (they al begni with FX_1.#######.####) Sometimes, there may be less numbers or more in the filename, that varies.
I wish to isolate just the... (8 Replies)