Skip to main content

All Questions

Tagged with
0 votes
4 answers
844 views

how to print first word from a string with multiple words without space?

I have a shell script to print appimage filenames inside a folder like this #! /bin/bash Dir="$HOME/Applications/" Dir2="$HOME/Downloads/" cd -P "$Dir" for f in *....
Ahmed Moselhi's user avatar
2 votes
1 answer
924 views

Why doesn't ampersand (&) work in string replacement without being escaped?

The following script is really simple, and replaces & with &: string="Foo & Bar" echo "${string//&/&}"; But the script does nothing. There are no ...
IQAndreas's user avatar
  • 10.6k
1 vote
1 answer
112 views

How to delete a string in my files?

So I want to match all below then remove those lines of string. [MTT-5634](https://my.atlassian.net/browse/MTT-5634) [MCC-123](https://my.atlassian.net/browse/MCC-123) [MTT-7965]: https://my.atlassian....
Beelzebub's user avatar
2 votes
2 answers
1k views

Search for a String in a file and save the string after it to a variable

Example: Lets say this is in a file: AB: Test CD: Testing EF: Rest I want a script to search for CD and save "Testing" into a variable. I've tried something with awk but somehow I'm not making any ...
Andehake's user avatar
2 votes
1 answer
3k views

How to mkdir or cp from Bash Script with Mixed Variable/String Literal Arguments?

I'm attempting to automate resetting a Minecraft world, and copying some custom functions back in... The reset just means deleting the world folder(s). Copying the custom functions to the right spot ...
HumanJHawkins's user avatar
0 votes
3 answers
1k views

determine if output is string or integer

I am trying to write a script which connects to a database then run a query that returns count of rows in a table. sometimes database or table have problems and instead of an integer they return an ...
BlackCrystal's user avatar
-1 votes
5 answers
98 views

simplify substring replacement list [closed]

I wrote a script that plays music. but the files have weird names. say I have this string of a filename Muzzy__Break_Away__28feat._Priority_One_29__5BMonstercat_EP_Release_5D.mp3 and I want to ...
KoneLinx's user avatar
5 votes
2 answers
10k views

Check if a file exists on a remote machine with spaces in the filename and/or path

I have a simple bash script; I basically want to make sure that the file exists on a remote machine. I've found numerous examples of how to do this, but the missing component is how to do this with ...
Allan's user avatar
  • 1,090
2 votes
1 answer
223 views

How can I use sed to snip a line off of a string?

I'm writing a script to display the domain registrar info and I'm trying to snip off a few lines from what I already have I currently have it grabbing all the indented text from a whois. Now I'm ...
Egrodo's user avatar
  • 207
1 vote
2 answers
2k views

How can I add a filter to my grep script to NOT include a string?

I'm working on a script that will separate the Registrar information from a domains whois. So far it's working enough but there are a few things that I want to remove in order for it to be a bit ...
Egrodo's user avatar
  • 207
1 vote
1 answer
438 views

Storing integer values from string in rrd

I want to collect stats from my DSL modem every 10 minutes. According to lots of websites it's best to use rrd for this. My modem(TD-W8968) struggles with SNMP so I've made an expect script to pull ...
Wilhelm Erasmus's user avatar
0 votes
1 answer
69 views

Substituting the value with spaces for a variable in bash script - the correct way

I have a compilation script that can compile the program with and without the debug symbols. I want to ask via bash prompt ( read ) the user to choose whether he wants a debug version or not with ...
Mindaugas Bernatavičius's user avatar
0 votes
1 answer
482 views

Take output field data string into variable

I want to grep for some specific lines from a log file, and then capture a specific part of that output in a variable and use it in other commands. The grep command I have is the following, where $1 ...
Asif's user avatar
  • 321
2 votes
2 answers
217 views

How to transform string with character codes into quoted form

I have a string like New\x20Folder. Special characters is represented by their codes. I'd like to transform the string into quoted form: "New Folder". The only available tools are bash and bunch of ...
ayvango's user avatar
  • 397
48 votes
6 answers
211k views

How to capture error message from executed command?

I was tasked to create an automated server hardening script and one thing that they need is a report of all the output of each command executed. I want to store the error message inside a string and ...
Miguel Roque's user avatar

15 30 50 per page