Sponsored Content
Top Forums Shell Programming and Scripting Extract filename from a given string Post 302947023 by sidnow on Sunday 14th of June 2015 06:42:53 PM
Old 06-14-2015
Extract filename from a given string

I want to extract the filename from a string.

This is how I have the rawdata ina file


/home/sid/ftp/testing/abc.txt
/home/sid/ftp/tested/testing/def.txt
/home/sid/sftp/date/misc/hij.txt


i want a script which would provide me an output like this

Directory Filename
/home/sid/ftp/ abc.txt
/home/sid/ftp/tested/testing def.txt
/home/sid/sftp/date/misc hij.txt

All help appreciated.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract only filename

Hi, I want to display only the file names of the ls command with a delimiter of comma. For example:- ls /etc/dir/N* gives the following output /etc/dir/N1 /etc/dir/N2 /etc/dir/N3 I want the output as N1,N2,N3,-->Here i need the final comma also. Also, here /etc/dir is being... (2 Replies)
Discussion started by: dnat
2 Replies

2. Shell Programming and Scripting

extract string portion from filename using sed

Hi All, I posted something similar before but I now have a another problem. I have filenames as below TOP_TABIN240_20090323.200903231830 TOP_TABIN235_1_20090323.200903231830 i need to extract the dates as in bold. Using bash v 3.xx Im trying to using the print sed command but... (11 Replies)
Discussion started by: santam
11 Replies

3. Shell Programming and Scripting

How to extract timestamp from the filename?

Hi., My file name is of the format: name_abc_20100531_142528.txt where., my timestamp is of the format: yyyymmdd_hhmmss How to extract the date strring and time string into seperate variables in the shell script, after reading the file as the input? I want to get the variables... (9 Replies)
Discussion started by: av_vinay
9 Replies

4. Shell Programming and Scripting

loop and extract matching filename

i am unable to exact matching filename in the loop. Filename.in file contains Customer_Product_ Information_Customer_Product_ sale_Product_ /home_dir contains files CUST_INFO_990090_1111.csv "1","Customer Product Detail","1000","salary" "1","Information Customer Product... (2 Replies)
Discussion started by: onesuri
2 Replies

5. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

6. Shell Programming and Scripting

extract every filename containing certain string in a directory and do some commend per file

Hi, Here is my question: suppose I have files like 1990_8xdaily_atmos.nc 1991_8xdaily_atmos.nc 1992_8xdaily_atmos.nc 1993_8xdaily_atmos.nc 1990_daily_atmos.nc 1991_daily_atmos.nc 1992_daily_atmos.nc 1993_daily_atmos.nc 1990_month_atmos.nc 1991_month_atmos.nc 1992_month_atmos.nc... (1 Reply)
Discussion started by: 1988PF
1 Replies

7. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

8. UNIX for Dummies Questions & Answers

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv OTP_UFSC_20120530000000_prom.csv... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

9. Programming

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My code: if then set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator"\ "pam_account"; for i in 1 2 3 4 5 6 7 8;... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

10. Shell Programming and Scripting

Extract string from filename

Hi I need to extract the string from file name filename: FILENAME_STRUT_01032013_XXXXXXX.TXT I want 01032013 from the above file name. number of characters may differ before the required string but underscores(-) are same number i.e. after second underscore. Please advise on this. ... (2 Replies)
Discussion started by: cnrj
2 Replies
GIT-FTP(1)						      General Commands Manual							GIT-FTP(1)

NAME
Git-ftp - FTP done the Git way SYNOPSIS
git-ftp [actions] [options] [url]... DESCRIPTION
This manual page documents briefly the git-ftp program. Git-ftp is a FTP client using Git to determine which local files to upload or which files should be deleted on the remote host. It saves the deployed state by uploading the SHA1 hash in the .git-ftp.log file. There is no need for Git (http://git-scm.org) to be installed on the remote host. Even if you play with different branches, git-ftp knows which files are different and only handles those files. No ordinary FTP client can do this and it saves time and bandwith. Another advantage is Git-ftp only handles files which are tracked with Git (http://git-scm.org). ACTIONS
init Initializes the first upload to remote host. push Uploads files which have changed since last upload. catchup Uploads the .git-ftp.log file only. We have already uploaded the files to remote host with a different program and want to remember its state by uploading the .git-ftp.log file. show Downloads last uploaded SHA1 from log and hooks `git show`. add-scope <scope> Creates a new scope (e.g. dev, production, testing, foobar). This is a wrapper action over git-config. See SCOPES section for more information. remove-scope <scope> Remove a scope. help Prints a usage help. OPTIONS
-u [username], --user [username] FTP login name. If no argument is given, local user will be taken. -p [password], --passwd [password] FTP password. If no argument is given, a password prompt will be shown. -k [[user]@[account]], --keychain [[user]@[account]] FTP password from KeyChain (Mac OS X only). -a, --all Uploads all files of current Git checkout. -c, --commit Sets the SHA1 hash of last deployed commit by option. -A, --active Uses FTP active mode. -s <scope>, --scope <scope> Using a scope (e.g. dev, production, testing, foobar). See SCOPE and DEFAULTS section for more information. -l, --lock Enable remote locking. -D, --dry-run Does not upload or delete anything, but tries to get the .git-ftp.log file from remote host. -f, --force Does not ask any questions, it just does. -n, --silent Be silent. -h, --help Prints some usage information. -v, --verbose Be verbose. -vv Be as verbose as possible. --syncroot Specifies a directory to sync from as if it were the git project root path. --connections Number of simultanious connections (Linux only). --version Prints version. URL
The scheme of an URL is what you would expect protocol://host.domain.tld:port/path Below a full featured URL to host.exmaple.com on port 2121 to path mypath using protocol ftp: ftp://host.example.com:2121/mypath But, there is not just FTP. Supported protocols are: ftp://... FTP (default if no protocol is set) sftp://... SFTP ftps://... FTPS ftpes://... FTP over explicit SSL (FTPES) protocol DEFAULTS
Don't repeat yourself. Setting defaults for git-ftp in .git/config $ git config git-ftp.<(url|user|password)> <value> Everyone likes examples $ git config git-ftp.user john $ git config git-ftp.url ftp.example.com $ git config git-ftp.password secr3t $ git config git-ftp.connections 10 $ git config git-ftp.syncroot path/dir After setting those defaults, push to john@ftp.example.com is as simple as $ git ftp push SCOPES
Need different defaults per each system or environment? Use the so called scope feature. Useful if you use multi environment development. Like a development, testing and a production environment. $ git config git-ftp.<scope>.<(url|user|password)> <value> So in the case below you would set a testing scope and a production scope. Here we set the params for the scope "testing" $ git config git-ftp.testing.url ftp.testing.com:8080/foobar-path $ git config git-ftp.testing.password simp3l Here we set the params for the scope "production" $ git config git-ftp.production.user manager $ git config git-ftp.production.url live.example.com $ git config git-ftp.production.password n0tThatSimp3l Pushing to scope testing alias john@ftp.testing.com:8080/foobar-path using password simp3l $ git ftp push -s testing Note: The SCOPE feature can be mixed with the DEFAULTS feature. Because we didn't set the user for this scope, git-ftp uses john as user as set before in DEFAULTS. Pushing to scope production alias manager@live.example.com using password n0tThatSimp3l $ git ftp push -s production You can also create scopes using the add-scope action. All settings can be defined in the URL. Here we create the production scope using add-scope $ git ftp add-scope production ftp://manager:n0tThatSimp3l@live.example.com/foobar-path Deleting scopes is easy using the remove-scope action. $ git ftp remove-scope production IGNORING FILES
Add file names to .git-ftp-ignore to be ignored. Ignoring all in Directory config: config/* Ignoring all files having extension .txt in ./ : *.txt This ignores a.txt and b.txt but not dir/c.txt Ingnoring a single file called gargantubrain.txt: gargantubrain.txt EXIT CODES
There are a bunch of different error codes and their corresponding error messages that may appear during bad conditions. At the time of this writing, the exit codes are: 1 Unknown error 2 Wrong Usage 3 Missing arguments 4 Error while uploading 5 Error while downloading 6 Unknown protocol 7 Remote locked 8 Not a Git project KNOWN ISSUES &; BUGS The upstream BTS can be found at <http://github.com/resmo/git-ftp/issues>. AUTHORS
Rene Moser <mail@renemoser.net>. git-ftp User Manual December 23, 2010 GIT-FTP(1)
All times are GMT -4. The time now is 06:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy