Skip to content

Tag: sh

How to write shell script,to automate file conversion?

I have 30 files(ascii),which I want convert to binary.Linux command line(FORTRAN 77 CODE) that has been compiled Relevant part of the code Then code asks for input and output file names How to automate this?I have tried like this Or But I do not have a clue for next step.Text files are Output files Answer Try…

Are linux shell pipes pipelined?

Given a file input.txt if I do something like is the output from the first command continuously passed (as soon as it is generated) as input to the second command? Or does the pipe wait until the first command finishes to start running the second command? Answer Yes, they’re pipelined — each compo…

Can I use hexdump in a shell script?

Can I use hexdump in a shell script? When I use it I keep getting an error . syntax error near unexpected token ‘hexdump’ I am not able to figure out why the hexdump code is giving me an error . Please help . Answer You are missing the do in your for loop:

Undersired echo truncate in sh Linux

I want to send two variables as input to another command in shell script. I have tried many methods to send the two variables but I am getting unexpected problems with echo command. the above string gives unexpected truncated output.i am getting the Variables after reading from a file.(ex : HOURS1=cat time_no…

check if a file is jpeg format using shell script

I know I can use file pic.jpg to get the file type, but how do I write an if statement to check it in a shell script? E.g. (pseudo code): Answer Try (assumes Bash v3.0+, using =~, the regex-matching operator): If you want to match file’s output more closely: This will only match if the output starts wit…

How to execute sh command set in shell variable?

I have this linux command: candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2> /dev/null > /tmp/can.log & It works correctly when I run it directly in shell. I want to add it in my script with this method: When I execute my script I get this error: SIOCGIFINDEX: No such device I have tested these scrip…