[raspberry-vi] Re: editing scripts

  • From: Mewtamer <mewtamer@xxxxxxxxx>
  • To: raspberry-vi@xxxxxxxxxxxxx
  • Date: Wed, 20 Jan 2021 20:38:43 +0000

You could try something like

for file in *.sh; do tr -d < "$file" > "new_$file" done

In general, this is useful for doing batch opporations when the
command to be executed doesn't support the use of * as a wildcard or
when the number of files to be acted on is too great to fit in a
single argument list. And since we're talking scripts, inserting
linebreaks after do and before done, you can define a series of
commands to be executed for every file in *.sh... and you can add
other extensions to the for file in line(e.g. for file in *.txt *.html
will execute the command between do and done on every file ending with
either .txt or .html).



On 1/20/21, Glenn K0LNY <glennervin@xxxxxxxxxxxx> wrote:

Tim,
I just tried
tr -d < *.sh
and it errored with ambiguous *.sh
Apparently I cannot do this to everything in a folder?

----- Original Message -----
From: "Tim Chase" <raspberry-vi@xxxxxxxxxxxxxxxxx>
To: <raspberry-vi@xxxxxxxxxxxxx>
Sent: Wednesday, January 20, 2021 2:04 PM
Subject: [raspberry-vi] Re: editing scripts


I suspect that the script contents contain Windows line-endings
(carriage-return, line-feed) rather than Unix line-endings (just a
line-feed).  You can strip out the carriage-return characters (\015
octal or 0x0D hexadecimal) easily enough with

  tr -d '\015' < script.sh > new_script.sh

and make the new_script.sh executable with

  chmod +x new_script.sh

If new_script.sh now works for you, that was the issue and you can
move it back overtop the original:

  mv new_script.sh script.sh

-tim

On January 20, 2021, Glenn K0LNY wrote:
Hi All,
So I made my scripts in windows, and they don't run.
I ran it in the terminal, and the last line error reads:
:numeric argument required
I'm wondering if that is referring to that I left out the line at
the end: exit 0
Here's the file contents:
#!/bin/bash
rtl_fm -M am -f 027.185M -s 22k | play -t raw -r 22k -es -b 16 -c 1
-V1 -


This command works when I type it in.
I did chmod +x *.sh in the folders with the .SH files.
Thanks.

Glenn
===========================================================
The raspberry-vi mailing list
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the
Raspberry Pi Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the
views and attitudes expressed by the subscribers to this list do
not reflect those of the Foundation.

Mike Ray, list creator, January 2013

===========================================================
The raspberry-vi mailing list
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and

attitudes expressed by the subscribers to this list do not reflect those of

the Foundation.

Mike Ray, list creator, January 2013

===========================================================
The raspberry-vi mailing list
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and
attitudes expressed by the subscribers to this list do not reflect those of
the Foundation.

Mike Ray, list creator, January 2013


=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

Other related posts: