Sponsored Content
Full Discussion: Pipe text in to find command
Top Forums UNIX for Advanced & Expert Users Pipe text in to find command Post 302593775 by juanjanse on Saturday 28th of January 2012 02:36:05 PM
Old 01-28-2012
Pipe text in to find command

I would like to know why this command does not work.
I have a script which connects to and ftp site.
After getting the remote files localy i need move each remote file to a archive folder on the FTP site

*Please also note that some of the files have spaces in the file name.

Im trying to extract the list of files names from the temp output file temp_rem_file_list.

Code:
 
echo "$TIME_STAMP - TEST MODE"
REMOTE_FILELIST=`ftp -in <<EOF
open $REMOTE_SERVER
user $USER $PW
cd $IN_REMOTE_SOURCE_DIR
ls
quit
 
echo $REMOTE_FILE_LIST > temp_rem_file_list
cat temp_rem_file_list
cat temp_rem_file_list |find "*.txt" -printf %f\\n >downloadList
echo "$TIME_STAMP - Printing download list"
cat downloadList
rm temp_rem_file_list
 
 
for SERVER_FILE in `cat downloadList`
 do
 echo "$TIME_STAMP - Server file processing is $SERVER_FILE"
   if [ -e "$IN_LOCAL_TARGET_DIR/$SERVER_FILE" ];then
   #if the file exists on the local machine
   else
   #File does not exist 
 fi

contents of temp_rem_file_list

Code:
 open localhost user if_jjan welcome1 cd Out ls drw-rw-rw- 1 ftp ftp 0 Jan 27 11:40 . drw-rw-rw- 1 ftp ftp 0 Jan 27 11:40 .. drw-rw-rw- 1 ftp ftp 0 Jan 26 00:33 archive -rw-rw-rw- 1 ftp ftp 0 Jan 27 11:21 test.txt -rw-rw-rw- 1 ftp ftp 0 Jan 27 11:22 UBS-test 1 test.txt -rw-rw-rw- 1 ftp ftp 0 Jan 27 11:23 UBS-test 2 test.txt quit

Line of code giving the problem.
Code:
 
cat temp_rem_file_list |find "*.txt" -printf %f\\n >downloadList

Im expecting downloadList to contain the following file names
test.txt
UBS-test 1 test.txt
UBS-test 2 test.txt

Thank you in advance for your time and for any pointers.

Last edited by juanjanse; 01-28-2012 at 06:30 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looking for command(s)/ script to find a text string within a file

I need to search through all files with different file suffixes in a directory structure to locate any files containing a specific string (5 Replies)
Discussion started by: wrwelden
5 Replies

2. UNIX for Dummies Questions & Answers

sorting files with find command before sending to text file

i need help with my script.... i am suppose to grab files within a certain date range now i have done that already using the touch and find command (found them in other threads) touch -d "$date_start" ./tmp1 touch -d "$date_end" ./tmp2 find "$data_location" -maxdepth 1 -newer ./tmp1 !... (6 Replies)
Discussion started by: deking
6 Replies

3. UNIX for Dummies Questions & Answers

AWK Command to find text in specific column

I'm new to scripting and would appreciate any help. I have a list of over 20 words in File1 that I need to find in columns 10-15 of File2. I need the entire row of File2 that the File1 list matches. I originally used a grep command which works, but provides File1 results that can be found... (3 Replies)
Discussion started by: Chillin
3 Replies

4. Shell Programming and Scripting

How to redirect a input of find command into a text file

Hello friends, I want a command to print the reult files from find command into a text file.:) Iam looking from forum memebers. PLZ help me.ASAP Thanks in Advance, Siva Ranganath CH (5 Replies)
Discussion started by: sivaranga001
5 Replies

5. UNIX for Dummies Questions & Answers

using grep command to find the pattern of text in all directories.

Hi all, i want to know the usage of grep command to find the pattern of text in all the directory and subdirectory. (1 Reply)
Discussion started by: vinothrajan55
1 Replies

6. UNIX for Dummies Questions & Answers

How to pass file text into find command

Hi all, I have a large text file and also a smaller list of program names. I want to find out how many of those programs exist in the large text file. Can someone help me with the command/script please. The program list is along the lines of tranwe2 tranwe3 tranye5 etc so basically I... (5 Replies)
Discussion started by: Grueben
5 Replies

7. Linux

Search only text files with 'find' command?

I've been using this to search an entire directory recursively for a specific phrase in my code (html, css, php, javascript, etc.): find dir_name -type f -exec grep -l "phrase" {} \; The problem is that it searches ALL files in the directory 'dir_name', even binary ones such as large JPEG... (2 Replies)
Discussion started by: Collider
2 Replies

8. Shell Programming and Scripting

Match text and print/pipe only that text

I'm trying to pull an image source url from a html source file. I'm new with regex. I'm in BaSH. I've tried grep -E 'http.*jpg' file which highlights the text, but gives me 2 problems: 1) Results aren't stand alone and can't be piped to another command. (I believe it includes everything in... (5 Replies)
Discussion started by: amx401
5 Replies

9. SuSE

Find command doesn't pipe the output as required.

Hi, I am using below code snippet to echo/display the files found (matching a pattern from searchstring.out file) and the corresponding owner. while read j do echo "Pattern to search is:- $j" find / -name "*$j*" |\ while read k do echo "File found is:- $k" owner=$(ls... (9 Replies)
Discussion started by: Vipin Batra
9 Replies

10. Shell Programming and Scripting

Find or ls with pipe to the command file

Hello all! I am trying to find the "Notes" backup from my iPhone in my folder ~/Library/Application\ Support/MobileSync/Backup/ which used to be in the sqlite file ca3bc056d4da0bbf88b5fb3be254f3b7147e639c. But since an update of the MacOS it is still there, but not updated anymore. (This is... (9 Replies)
Discussion started by: marek
9 Replies
ftpd_selinux(8) 					 ftpd SELinux policy documentation					   ftpd_selinux(8)

NAME
ftpd_selinux - Security-Enhanced Linux policy for ftp daemons. DESCRIPTION
Security-Enhanced Linux provides security for ftp daemons via flexible mandatory access control. FILE_CONTEXTS SELinux requires files to have a file type. File types may be specified with semanage and are restored with restorecon. Policy governs the access that daemons have to files. Allow ftp servers to read the /var/ftp directory by adding the public_content_t file type to the directory and by restoring the file type. semanage fcontext -a -t public_content_t "/var/ftp(/.*)?" restorecon -F -R -v /var/ftp Allow ftp servers to read and write /var/tmp/incoming by adding the public_content_rw_t type to the directory and by restoring the file type. This also requires the allow_ftpd_anon_write boolean to be set. semanage fcontext -a -t public_content_rw_t "/var/ftp/incoming(/.*)?" restorecon -F -R -v /var/ftp/incoming BOOLEANS
SELinux policy is based on least privilege required and may also be customizable by setting a boolean with setsebool. Allow ftp servers to read and write files with the public_content_rw_t file type. setsebool -P allow_ftpd_anon_write on Allow ftp servers to read or write files in the user home directories. setsebool -P ftp_home_dir on Allow ftp servers to read or write all files on the system. setsebool -P allow_ftpd_full_access on Allow ftp servers to use cifs for public file transfer services. setsebool -P allow_ftpd_use_cifs on Allow ftp servers to use nfs for public file transfer services. setsebool -P allow_ftpd_use_nfs on system-config-selinux is a GUI tool available to customize SELinux policy settings. AUTHOR
This manual page was written by Dan Walsh <dwalsh@redhat.com>. SEE ALSO
selinux(8), ftpd(8), setsebool(8), semanage(8), restorecon(8) dwalsh@redhat.com 17 Jan 2005 ftpd_selinux(8)
All times are GMT -4. The time now is 04:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy