I need to write a script to count the number of tabs in each line of a file and print the output to a text file (e.g., output.txt). How do I do this? Answer
Tag: shell
How can I use an at command in a shell script?
I am trying to use the Unix at command (for setting a job to run at a certain time) in a shell script. The time will be specified by user input using getopts and optarg which seem to be working fine, the problem is at. How do I write the at command into the script to run at a certain
How to read a property value of json file located local on Ubuntu Terminal
I have a json file like below: and how can I read this value on Ubuntu Terminal. Answer You didn’t mention which version of ubuntu but as a 1 liner from the terminal this works for me (assumes json file is in same directory and called json_file.json)
inputrc file cannot be loaded [closed]
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 10 years ago. Improve this question I just figured out we can create a ~/.inputrc file to define keyboard mappings. But I don’t …
Advantage of $PATH over alias
I am relatively new to Linux and Unix. With the help of the internet I finally figured out how $PATH and aliases in my .bashrc work. But I really couldn’t find anything that describes when to use which. Let’s say I installed Python3.3 in Library/Frameworks and the executable is /Library/Frameworks…
How to get file creation date/time in Bash/Debian?
I’m using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time. ls -lh a.txt and stat -c %y a.txt both only give the modification time. Answer Unfortunately your quest won’t be possible in general, as there are only 3 distinct time values …
Bash Shell Script – Check for a flag and grab its value
I am trying to make a shell script which is designed to be run like this: Firstly, in my script I want to check to see if the script has been run with the -t flag. For example if it has been run without the flag like this I want it to error: Secondly, assuming there is a -t flag,
I need get a substring in Shell Script
i need help. I need get a substring in the next line the result must be: ttl 128 I hope you can help me! Thanks! Answer Try doing this : NOTE b is a word boundary s is a space + mean at least one or more preceding character -P switch is pcre advanced useful syntax for grep -o switch
How to toggle case for text in a file [closed]
It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago. I want to know the …
Linux shell script to find and rename files to remove suffix?
I have some files named like this: file1.c.keep.apple file2.c.keep.apple I am trying to write a shell script so that I pass in the suffix as an argument (in this case, apple) and it will rename all of the files removing the .keep.apple. Example execution: script.sh apple results in the files above being renam…