Sponsored Content
Top Forums Shell Programming and Scripting SED: Removing Filenames From Paths Post 302399033 by ungalnanban on Friday 26th of February 2010 05:37:04 AM
Old 02-26-2010
MySQL

see using SED we can replace the filename in path.

Code:
sed 's%/[A-z]*$%/.%g' path



Input:
/u/dir1/dir2/dir3/file
/u/dir1/dir2/file
/u/dir1/file

Output:
/u/dir1/dir2/dir3/.
/u/dir1/dir2/.
/u/dir1/.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

removing the extension from all filenames in a folder

Hi there, I'm pretty new to UNIX and have tried trawling through this forum to find an answer to what I want to try to do, which I'm sure is very simple but I don't know how to do it. What I have a a folder that contains multiple files that I have copied from Windows and I want to remove the... (5 Replies)
Discussion started by: johnmcclintock
5 Replies

2. Shell Programming and Scripting

Removing a character using sed

Hi, I have a file with the text below. How do i remove the character "%" from the text file using sed ? Can anybody help ? 0% 68% 72% 0% 54% 33% 75% 24% 6% 59% 77% 77% 33% (6 Replies)
Discussion started by: Raynon
6 Replies

3. UNIX for Dummies Questions & Answers

sed to isolate file paths separated by a pattern

Hi, I've been searching for a quick way to do this with sed, but to no avail. I have a file containing a long series of (windows) file paths that are separated by the pattern '@'. I would like to extract each file path so that I can later assign a variable to each path. Here is the file:... (2 Replies)
Discussion started by: nixjennings
2 Replies

4. Shell Programming and Scripting

Renaming Movies (or Flipping Portions of Filenames Using sed or awk)

Hey folks My problem is simple. For my first stash of movies, I used a naming convention of YEAR_MOVIE_NAME__QUALITY/ for each movie folder. For example, if I had a 1080p print of Minority Report, it would be 2002_Minority_Report__1080p/. The 2nd time around, I changed the naming convention... (4 Replies)
Discussion started by: ksk
4 Replies

5. UNIX for Dummies Questions & Answers

Question/review my script: removing bad chars from filenames

The task: remove undesirable characters from filenames. Restrictions: Must use basic RE, base utilities (non-GNU) and /bin/sh (ash). No ksh, zsh, perl, etc. Below is what I've come up with. It seems to work OK but I'm open to shorter, more efficient alternatives. Inside the square... (4 Replies)
Discussion started by: uiop44
4 Replies

6. Shell Programming and Scripting

removing spaces in filenames

I have a problem mounting images because of the spaces in the filenames. Does anyone know how to rename files by removing the spaces with the find command? find Desktop/$dir -name "*.dmg" -print -exec ??? (4 Replies)
Discussion started by: ianebaj
4 Replies

7. Shell Programming and Scripting

SED removing CR/LF

I have a source text file that contains something like this: <start_template> bool function( void *<var_name> ) { // Blah Blah } </start_template> Following is used to remove this template from source file. template=$(sed -n -e '/<start_template>/,/<\/start_template>/{... (4 Replies)
Discussion started by: gee22
4 Replies

8. Solaris

Removing Dead Paths And Unusable Path Solaris 9

Hi, One of our Solaris servers was peviously zoned and connected to 2 seperate arrays, one HP and the other EMC. The server is now only connected to the EMC. The sever has x2 single port HBA's. When running cfgadm I see the following: root@qwicprod /dev/rdsk]# cfgadm -al Ap_Id Type... (6 Replies)
Discussion started by: jamba1
6 Replies

9. Shell Programming and Scripting

Removing quotes in sed

I have a file and I want to remove quotes from the word " ` " through sed command but unable to remove I am using below command sed s/"`XYZ`"/"ZXY"/g file1.txt > file2.txt But this is not working. How can we remove "`" through sed command (2 Replies)
Discussion started by: kaushik02018
2 Replies

10. Shell Programming and Scripting

Show only the filenames under a directory without relative and absolute paths.

I am able to list all the filenames under a directory & its sub-directories except blent.tar on Linux find "/tmp/" -type f | grep -v blent.tar | rev | cut -d '/' -f1 | rev Desired Output: THIRDPARTYLICENSEREADME.txt javaws libjavaplugin_oji.so libjavaplugin_oji.so... (3 Replies)
Discussion started by: mohtashims
3 Replies
SLOCATE(1)						      General Commands Manual							SLOCATE(1)

NAME
slocate - Security Enhanced version of the GNU Locate SYNOPSIS
slocate [-qi] [-d <path>] [--database=<path>] <search string> slocate [-i] [-r <regexp>] [--regexp=<regexp>] slocate [-qv] [-o <file>] [--output=<file>] slocate [-e <dir1,dir2,...>] [-f <fstype1,...>] <[-l <level>] [-c] <[-U <path>] [-u]> slocate [-Vh] [--version] [--help] DESCRIPTION
Secure Locate provides a secure way to index and quickly search for files on your system. It uses incremental encoding just like GNU locate to compress its database to make searching faster, but it will also store file permissions and ownership so that users will not see files they do not have access to. This manual page documents the GNU version of slocate. slocate Enables system users to search entire filesystems without displaying unauthorized files. OPTIONS -u Create slocate database starting at path /. -U <dir> Create slocate database starting at path <dir>. -e <dir1,dir2,...> Exclude directories from the slocate database. -f <fstype1,...> Exclude files on specific file systems from the slocate database. -c Parse '/etc/updatedb.conf' when updating the slocate database. -l <level> Security level. 0 turns security checks off. This will make searchs faster. 1 turns security checks on. This is the default. -i Does a case insensitive search. -q Quiet mode. Error messages are suppressed. -n <num> Limit the amount of results shown to <num>. -r <regexp> --regexp=<regexp> Search the database using a basic POSIX regular expression. -o <file> --output=<file> Specifies the database to create. -d <path> --database=<path> Specifies the path of databases to search in. -h --help Display this help. -v --verbose Verbose mode. Display files when creating database. -V --version Display version. VERSION
Secure Locate v2.6 AUTHOR
Kevin Lindsay - Copyright (c) 1999, 2000 BUG REPORT
Report any bugs to klindsay@mkintraweb.com FTP
ftp://ftp.geekreview.org/slocate/ ftp://ftp.mkintraweb.com/pub/linux/slocate/ WEB
http://www.geekreview.org/slocate/ SLOCATE(1)
All times are GMT -4. The time now is 08:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy