Em Andamento

Edit Bash Script - Looping

I currently have a simple bash script that takes input from a file (list of files) and then outputs the list of files with associated checksums.

I would like the script to have a little more logic by checking for a string in the file list and upon finding the string do something else echo the file name.

## Deliverables

I want to take the script below:

*********

Start

*********

#!/bin/bash

#Useage: ./[url removed, login to view] < input_list_file > output_with_checksum_file

PASSED=0

while read line;

do

for i in `find $line -type f 2> /dev/null`;

do

CHECKSUM=`sha256sum $i | awk -F' ' '{ print $1}'`

echo -e "$CHECKSUM,$i"

done

done

exit $PASSED

***********

End

***********

What I want to do is now read a input_list_file that has two inputs per line. Text is similar to below:

*********

Input File

*********

SEMI-STATIC,/bin/bash

STATIC,/bin/date

STATIC,/bin/ln

DYNAMIC,/bin/sed

STATIC,/boot/[url removed, login to view]

STATIC,/boot/grub/[url removed, login to view]

STATIC,/boot/grub/e2fs_stage1_5

I want to go through each line. If the line starts with STATIC, I want to get the sha256sum on the file on the same line, if is is something such as SEMI-STATIC or DYNAMIC we do not need to get the sha256sum.

*********

Output file (want)

**********

The output for the test file would be something like:

SEMI-STATIC,/bin/bash

a90a91f4d2bb0045e1236bfe40fee45fd962cbfa817c0b87f0bcb5de659795b1,/bin/date

9c6e065feb118495451d4bb700e33d0beec80cf9d428120d28f262012c1a892a ,/bin/ln

DYNAMIC,/bin/sed

dc98737b41f7c03b8e990907f177838e6a476df3dfe536f19f3a464348a6f1a7 ,/boot/[url removed, login to view]

30af49966c8f9f834e4fbf3f855b54d4fdd3afa219bacfedf2368f81380d9cc5,/boot/grub/[url removed, login to view]

500fe58d8de689822f5d4ffdef8fa671cb7bcbe84eb687853d71075641b86e98,/boot/grub/e2fs_stage1_5

I've made some attempts myself (below), but haven't gotten anything good.

********

Attempted Script

********

#!/bin/bash

PASSED=0

ORIGIFS=$IFS

IFS=","

while read status file

do

if [$status=STATIC];

then

CHECKSUM=`sha256sum $file`;

echo -e "$CHECKSUM,$file" ;

else

echo "$status,$file" ;

fi

done

exit $PASSED

Habilidades: Engenharia, Linux, MySQL, PHP, Gestão de projetos, Arquitetura de software, Teste de Software

Ver mais: php script null, map string, bash file, bash 0, t sh, sh, ln, linux device, linux bash script, edit something 2, edit bin file, bash script, awk, linux read text file, map edit, php string checksum, linux boot device, php echo print, linux file edit, edit output, php script echo, echo script php, dynamic map php, echo script, echo file php

Acerca do Empregador:
( 44 comentários ) United States

ID do Projeto: #3025358

Premiar a:

ilnlivw

See private message.

$12 USD em 1 dia
(23 Avaliações)
3.9

10 freelancers estão ofertando em média $10 para este trabalho

kingcodersl

See private message.

$12.75 USD em 1 dia
(75 Comentários)
4.6
Cway

See private message.

$8.5 USD em 1 dia
(10 Comentários)
3.8
peanuxsl

See private message.

$5.1 USD em 1 dia
(34 Comentários)
3.5
kanhashriinc

See private message.

$10.2 USD em 1 dia
(9 Comentários)
2.9
solesilentcoder

See private message.

$8.5 USD em 1 dia
(8 Comentários)
2.8
jack0stone

See private message.

$12.75 USD em 1 dia
(9 Comentários)
2.6
fabulousronin

See private message.

$6.8 USD em 1 dia
(4 Comentários)
1.0
sahilsmarrty

See private message.

$11.9 USD em 1 dia
(2 Comentários)
0.0
ilievalentinvw

See private message.

$12.75 USD em 1 dia
(0 Comentários)
0.0