bash if statement help needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash if statement help needed
# 1  
Old 07-14-2012
bash if statement help needed

Hi I need a script with an if statement that goes.

I need it to search through all files within a directory with the extension .test if it finds the string '71502FSC1206' then do
Code:
sed 's/71502FSC1206/\n&/g' > send.test

If it finds the string '715MCH' or '715JAC' then I need it to move the file to another directory.

Thanks in advance

Last edited by Franklin52; 07-14-2012 at 06:34 AM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 07-14-2012
Please post in the homework forum,or establish some commercial context.

Please remember to post what Operating System and version you have and what Shell you use.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bash statement equivalent

Hi all, i need a equivalent for the statement i run in bash, so it would also run in other shells. Specially i need it for ksh to run on AIX. Here the statements: exec > >(tee -a $log) exec 2> >(tee -a $log >&2) Thanks. (5 Replies)
Discussion started by: Kosak
5 Replies

2. Shell Programming and Scripting

[Solved] If statement in bash

I have the following code in bash, however "set red frmt" is not displayed. echo "iarg_rd = $iarg_rd" iarg_rd="2" if ; then echo "Hello World" fi if ; then frmt="${gap}${!frmt_titl_yl}" elif ; then frmt="${gap}${!frmt_titl_bk}" elif ; then echo... (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

BASH - case statement

Hi Gurus, I have the below BASH code which does not works for upper case alphabets except Z (upper case Z). What may be the reason. Also escape sequences like \n, \t, \b, \033(1m \033(0m (For bold letter) are not working. case $var in ) echo "Lower case alphabet" ;; ... (7 Replies)
Discussion started by: GaneshAnanth
7 Replies

4. UNIX for Dummies Questions & Answers

Bash - OR within an IF statement

Hey guys, Currently trying to write a wee script that runs only when logged in as one of two users. The rest of the script is working fine, but no matter what user I try to run it as, it always fails! This is the puzzling part:if ]; then echo "Run script as admin " exit 1 else... (6 Replies)
Discussion started by: jimbob01
6 Replies

5. Shell Programming and Scripting

Simple if statement help needed please

if ]; then echo "successssssssssssssssssss" $filename = "<font color='red'>$i</font>" else echo "failureeeeeeeeeeeeeeeeeeeee" $filename = "$i" fi; I'm just trying to see is this - read a file name and highlight... (2 Replies)
Discussion started by: vmanda
2 Replies

6. UNIX for Dummies Questions & Answers

Conditional statement in bash

I want to combine 2 conditional statements by using -o in bash, but it won't work. if ; then echo "The number needs to be between 0 and $nr" fi Each time i execute the file it says: ./selectCitaat: line 10: syntax error near unexpected token `$1' (3 Replies)
Discussion started by: doc.arne
3 Replies

7. Shell Programming and Scripting

Help Needed with 1 liner AWK statement

Greetings, I attempting to create a line statement that will do the following: 1. Read the input file 2. Extract lines containing certain keep words 3. Print the lines in a tabular format (CSV) Help is what I have so far: # cat text.tx | egrep -i -e "(Check Name) | (Risk Level) |... (6 Replies)
Discussion started by: jroberson
6 Replies

8. Shell Programming and Scripting

help needed with script that gets a filename as argument (with an if/else statement)

Hi, I am trying to create a script just to study BASH scripting, but I have some problems. I need to create a script that gets a filename as an argument. The script should behave as follows: • If the given file name already exists, inform the user and quit. • If the given file name does... (2 Replies)
Discussion started by: I-1
2 Replies

9. Shell Programming and Scripting

help needed in using case statement

Hi, I have a script as below: ....................................................................... rpttxt() { name="$*" awk '/'"${name}"'/ {print $2$3$4 }' file_1.txt } title="`rpttxt "TITLE"`" ......................................................................... The... (0 Replies)
Discussion started by: jisha
0 Replies

10. Shell Programming and Scripting

more elegant way for conditional statement needed

Hi all, I have a script which gets its input from a text file (file.txt) and processes each line within a loop. I have a counter which increases by one and I want something to happen every 7th, 14th, 21st, etc. line read. Currently the code looks and works perfectly like this: ... (3 Replies)
Discussion started by: candyflip2000
3 Replies
Login or Register to Ask a Question