Unix file redirect problems


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix file redirect problems
# 8  
Old 05-11-2010
fva* = command shell make filegeneration before find, result is not maybe what you are trying.
"fva*" = argument for find, no filegeneration.
Code:
# not so good
find /path  -name fva* -exec ls -lrt {} \; > x2.xls
# much better
find /path  -name "fva*" -exec ls -lrt {} \; > x2.xls

This User Gave Thanks to kshji For This Post:
# 9  
Old 05-20-2010
Grep command problms

Hi i hav a file as below
cat tciftp01.sh
Code:
# Assign job variables.
scriptname=ftp01.sh
parms=""
$BIN_DIR/$scriptname $parms

i wrote below line to get ftp01.sh script alone
Code:
grep -v "^#" tciftp01.sh | tr ' ' '\n' | tr '"' '\n' |  tr '=' '\n' |grep -E "\.ksh|\.sh"

but the server where im executing above line showing below error
Code:
grep: illegal option -- E

so how can i avoid this error and print ftp01.sh using grep command

Last edited by Yogesh Sawant; 05-20-2010 at 04:51 AM.. Reason: added code tags
# 10  
Old 05-20-2010
Hi.

You could try egrep (without the -E option), or use awk or sed for this:

Code:
$ sed -n "/^scriptname=/ s/.*=//p" tciftp01.sh
ftp01.sh

This User Gave Thanks to Scott For This Post:
# 11  
Old 05-21-2010
For loop problems

Hi, i wrote below FOR loop in my script which goes through every script in scripts.txt file and takes wherever FTP or SCP will be found
but while executing above script, it showing below error
: syntax error at line : `'' unmatched
Can you plz go through my for loop and tell me where is the exact problem?
Code:
echo "Script, ftp, scp > output.csv
for i in `cat scripts.txt`
do
b=""
c=""
d=""
        grep -i "ftp" $i 2>/dev/null
        if [ $? -ne 0 ];
        then
                b="N"
        else
                b=`grep -v "^#" $i | grep -i "ftp" $i `
        fi
        grep -i "scp" $i 2>/dev/null
        if [ $? -ne 0 ];
        then
                c="N"
        else
                c=`grep -v "^#" $i | grep -i "scp" $i `
        fi
        d=`echo "$i"|cut -f5 -d '/'`
        echo " "$d\",\"$b\",\"$c\"" >> output.csv
done

scripts.txt file will be something like this:
Code:
/opt/scripts/prod/vrc055135j.ksh
/opt/scripts/prod/vrc055140j.ksh
/opt/scripts/prod/vrc055210u.ksh

and it should print in below way in an excel.
Code:
Script    ftp       scp
vrc055135j.ksh  ftp -niv $dest  N
vrc055140j.ksh  N   N
vrc055210u.ksh  N   scp -b xxxxxxxxxxxxx


Last edited by Scott; 05-21-2010 at 09:25 AM.. Reason: Code tags, please...
# 12  
Old 05-25-2010
Unix file display problms

Hi, i have a file something like this.
Code:
$ cat scripts.txt
/opt/scripts/test.sh
/apps/opm/ctmagent/test2.sh
/apps/ascential/global/DS/scripts/test3.ksh
/projects/ascential/V9/env/setup.ksh
...
..
.

can u plz suggest me how can i write a code to print below o/p?

Code:
test.sh
test2.sh
test3.ksh
setup.ksh


Last edited by Scott; 05-25-2010 at 01:58 AM.. Reason: Code tags, please...
# 13  
Old 05-25-2010
Code:
$ sed 's/.*\///' scripts.txt
test.sh
test2.sh
test3.ksh
setup.ksh

# 14  
Old 06-03-2010
Thanks scottn, the sed command is working fine.
but im unable to understand the command
Code:
sed 's/.*\///'

, can you plz explain?

Last edited by Franklin52; 06-08-2010 at 05:22 AM.. Reason: Please use code tags!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C, UNIX: How to redirect 'stdout' to a file from a C code?

I am looking for a way to redirect standard output to a file from a C-code; so, any 'cout<<..' or 'printf(...)' will be written into a file. I have a server source that I need to debug. That program called by RPC (remote procedure call) and has no any session to print out anything. I have... (3 Replies)
Discussion started by: alex_5161
3 Replies

2. UNIX for Dummies Questions & Answers

Redirect to a file

Hi, Is there a way to redirect the output of a set of commands to a file instead of using << at every command in bash shell. For eg (echo hostname echo "Comparing 2 files" comm -3 file1 file2) >>file3 (3 Replies)
Discussion started by: Rossdba
3 Replies

3. Shell Programming and Scripting

Read file from input and redirect to output file

Hi , i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names for eg: file.txt contains file_name1.txt|hai file_name2.txt|bye file_name3.txt|how... (3 Replies)
Discussion started by: rohit_shinez
3 Replies

4. Shell Programming and Scripting

Redirect output from SQL to unix variable

Hi, I have a requirement to store oracle sqlplus output to some unix variable, count the records and then print the output on the screen. Can you please point me to any sample program for reference purpose. Thanks a lot for your time. (0 Replies)
Discussion started by: bhupinder08
0 Replies

5. UNIX for Dummies Questions & Answers

STDOUT redirect to file and format problems

Hi All, I am using centOS. When I try to redirect STDOUT to a file, it ends up in getting some funny characters. For example ... STDOUT of the command as follows. $ ls H3k27me3 H3k36me3 H3k4me1 H3k4me2 H3k4me3 H3k9ac H4k20me1 $ ls >test $ cat test ^ (1 Reply)
Discussion started by: Chulamakuri
1 Replies

6. Shell Programming and Scripting

ksh- redirect stderr to file and then modify the file

I have the following: remsh $host -n 2>>syslog_issue_list.txt grep -i -e "EMS" -e "error" -e "warning" -e "excessive" /var/adm/syslog/syslog.log | awk /"$DATE1"/ | awk -vhost="$host" '!/remsh|telnetd/{print host "\n", $0 >> "syslog_issue_list.txt"}' I am creating a health script that has... (4 Replies)
Discussion started by: chipblah84
4 Replies

7. Shell Programming and Scripting

Call and redirect output of Oracle stored procedure from unix script

Hi, Can you assist me in how to redirect the output of oracle stored procedure from unix script? Something similar to what i did for sybase isql -U$MYDBLOG -D$MYDBNAME -S$MYDBSVR -P$MYDBPWD -o$MYFILE<< %% proc_my_test 8 go %% Thanks in advance - jak (0 Replies)
Discussion started by: jakSun8
0 Replies

8. Shell Programming and Scripting

How to redirect value from sql select statment to unix variable

Hi, I need to get the value from the table using the sql command and store this value into the unix variable so that i can use this value for furthure use.. Please can any body help me in this regards Thanks & Regards Abdul Hafeez Shaik (17 Replies)
Discussion started by: abdulhafeez
17 Replies

9. HP-UX

how to redirect the growing contents of log file to another file in unix

how to redirect the growing contents of log file to another file in unix (2 Replies)
Discussion started by: megh
2 Replies

10. HP-UX

How to Redirect the error messages from Syslog file to our own Application Log File

Hello, I am New to Unix. I am Using HP-UX 9000 Series for my Application. I am Currently Facing an Issue that the error messages are being written in the syslog file instead of the Application Log File. The Codes for that Syslog.h is written in Pro*C. I want to know how to Redirect these... (3 Replies)
Discussion started by: balasubramaniam
3 Replies
Login or Register to Ask a Question